ESSENTIAL THEME: How can I make a standalone page my frontpage?

ESSENTIAL THEME: How can I make a standalone page my frontpage?

by shanthi peter -
Number of replies: 15

I have created a new standalone page in moodle and in that file I have used

$PAGE->set_pagelayout('frontpage');

Everything is displayed in the new page like the homepage BUT the list of courses are missing.

Please let me know why ?

(Edited by Mary Evans - changed subject heading - original submission Wednesday, 22 April 2015, 6:12 AM)

Average of ratings: -
In reply to shanthi peter

Re: frontpage layout ?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Well as far as I know $PAGE->set_pagelayout('frontpage'); is dictated by what is defined in $THEME->layouts in your theme's config.php, that is if they are listed there, otherwise it will follow the parent theme's definition of the frontpage layout.

The FRONTPAGE as you see it is defined in Moodle CORE and is an extension of the moodle/index.php

Hope this helps?

Mary

In reply to Mary Evans

Re: frontpage layout ?

by shanthi peter -
Sorry I should have been clear.
I'm using evolution theme and yes frontpage.php is defined as the layout 'frontpage' in the theme config.php.

I'm confused as to how the homepage shows list of courses but the new standalone page I created does not show them !
In reply to shanthi peter

Re: frontpage layout ?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Because it is NOT the frontpage it is just a stand alone page that has the same layout design but NOT the contents!

In reply to Mary Evans

Re: frontpage layout ?

by shanthi peter -

Hello Mary


This reply of yours got me thinking. Thanks for the pointer. SO what php code should I use  if I want to display the course list exactly like the index page.

In reply to shanthi peter

Re: frontpage layout ?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I am sorry to say, Shanthi, but I haven't a clue, Gareth is the one to ask as he maintains the Essential theme.

By the way I have changed the title of this discussion so that Gareth might read it.

Cheers

Mary

In reply to shanthi peter

Re: frontpage layout ?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

OK - I may be missing something here but...

'Everything is displayed in the new page like the homepage BUT the list of courses are missing.'

The list of courses is a content item that can be turned on or off in the front page. So, if you have everything displayed like the homepage AND you want the course list - why not just use the front page? OR just edit the frontpage layout file in your theme?

I don't understand the requirement for a completely separate standalone front page that essentially mirrors the one that's already there.

In reply to Richard Oelmann

Re: frontpage layout ?

by shanthi peter -

Actually I need a standalone page exactly like frontpage which I can modify slightly.

So the first step, I just used the 'frontpage' layout in a standalone page to see whether everything displays correctly in the standalone page. But I'm not able to display the list of courses at all in my standalone page

Once that is solved I plan to make a copy of frontpage layout and customize it further.

In reply to shanthi peter

Re: frontpage layout ?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
But why a standalone page? - I'm sorry I am missing something that is probably obvious to you, but I dont see it.
You want something that is exactly like a moodle front page, that contains all the automatic content of the moodle front page such as the course list, but you don't want it to be the moodle front page? hmmmm....

Are you accessing this standalone front page from within Moodle or is it to be a front end of a web portal that will eventually take people into the moodle courses?
If the first - just customise the frontpage.php layout.
If the second I'd suggest that the courses list is not there because the session key is not set in your standalone page away from moodle and so its not pulling all the courses from the database. The MAINCONTENT will probably need to be part of Moodle to get the session variables and populate that MAINCONTENT place holder. OR you need some way to pass the sesskey and other data to your standalone page outside Moodle.

In reply to Richard Oelmann

Re: frontpage layout ?

by shanthi peter -

"Are you accessing this standalone front page from within Moodle or is it to be a front end of a web portal that will eventually take people into the moodle courses?"

It is within moodle directory.

"If the first - just customise the frontpage.php layout."

I need the frontpage to be as it is. I need another standalone page to look like frontpage but with more customizations.

So I have created a standalone page with same frontpage layout but courses are not visible. Once they become visible I plan to copy frontpage->frontpage1 and then customize the frontpage1 layout.

SO in the end the usual frontpage will be visible and also the customized standalone page with customized frontpage layout too will be visible. They are 2 different pages.

Thanks.

In reply to shanthi peter

Re: frontpage layout ?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

So why not just customise the existing frontpage to add the extra customisations when the 'factor' that decides when the alternative is needed is 'true'?

In reply to Gareth J Barnard

Re: frontpage layout ?

by shanthi peter -

The "extra customizations"  will also remove some of the look and feel from the existing front page.

The standalone page will be under a link from the homepage. Both pages are needed.

Still I'm not able to view the list of courses in the standalone page even though I'm using the frontpage layout ?

In reply to shanthi peter

Re: frontpage layout ?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

As I keep telling you, the Frontpage layout has little to do with the content contained in the Frontpage itself. The layout only dictates if there are sideblocks, where the sideblocks will be visible, has it a header and footer, is there a breadcrumb navbar, is there a language menu, is there a custommenu, etc, etc.

As far as I know the frontpage content is set via moodle/index.php so perhaps you might like to look at that page and see if you can follow where the content comes from and how it gets put into the frontpage?

Cheers

Mary

In reply to shanthi peter

Re: frontpage layout ?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, even if you remove items, then you can still manipulate the existing frontpage.  Or, as Mary suggests, look at 'index.php' and go figure.

My Shoehorn theme has 'Sitepages' which manipulate the mechanism and add a new page type, which might be of interest in figuring out what to do: https://github.com/gjb2048/moodle-theme_shoehorn/blob/master/pages/sitepage.php

In reply to shanthi peter

Re: frontpage layout ?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi shanthi,

Where is your 'standalone' page kept in relation to the Evolve-D theme?

For it to be used as the frontpage it needs to be in the evolved/layout/ directory.

If you want it to take on the role as a 'frontpage' then you need to make it such by adding it to the $THEME->layouts = array like this...

https://github.com/lazydaisy/moodle/blob/master/theme/bootstrapbase/config.php#L76

by replacing

'file' => 'columns3',

with

'file' => 'your_stand_alone_page.php',

as that is the only way it will work.

Unless of course if you were wanting to do something else with your standalone page?

Hope this helps?

Mary

In reply to Mary Evans

Re: frontpage layout ?

by shanthi peter -

Hello Mary,

What was I even thinking ? It is essential theme and not evolution, which I'm using.

https://github.com/moodleman/moodle-theme_essential/blob/master/config.php#L50

and here the snippet of  code from the standalone.php, this script is present in the root folder of moodle.


$PAGE->set_pagetype('site-index');
    $PAGE->set_docs_path('');
    $PAGE->set_pagelayout('frontpage');
    $editing = $PAGE->user_is_editing();
    $PAGE->set_title($SITE->fullname);
    $PAGE->set_heading($SITE->fullname);
    $courserenderer = $PAGE->get_renderer('core', 'course');
    echo $OUTPUT->header();


I'm able to see everything present on index page except the list of courses.

Am I missing something ?