Is there a way to create a layour with no main content

Is there a way to create a layour with no main content

by Howard Miller -
Number of replies: 7
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You appear to be required to include the main content token in any layout page

<? echo core_renderer::MAIN_CONTENT_TOKEN ?>

An error is thrown if it's not found.

I'm trying to find some way of creating a theme with no main content. The reason is that I want to create a new login page that is completely custom. As login does not seem to have any renderers that I can override, the only way seems to be to completely replace it's layout page with my own content (forms, buttons and everything). The layour renderer doesn't seem to want to let me.


Yes, I know this is madness, but any thoughts?

EDIT:

In particular, this doesn't work
<?php ob_start(); ?>
<? echo core_renderer::MAIN_CONTENT_TOKEN ?>
<?php ob_end_flush(); ?>

.....I'm not sure I'm surprised. I take it the layout is 'interpreted' in some way and that echo statement is not actually echoing anything for real. I don't understand well enough how layouts work under the hood (or bonnet in proper English, of course big grin)

Average of ratings: -
In reply to Howard Miller

Re: Is there a way to create a layour with no main content

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Answering my own question...

<div id="nomaincontent>
<? echo core_renderer::MAIN_CONTENT_TOKEN ?>
</div>

And then simply set 'display:none" for that id. Still seems mad though....

In reply to Howard Miller

Re: Is there a way to create a layour with no main content

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

Hi Howard,

The Main content token you refer to above was changed to <?php echo $SOUTPUT->main_content(); ?> in Moodle 2.2+ No point in creating older versions of themes as Moodle 2.1 is not maintained for general bugs now, it's only getting security fixes.

That said...the only thing you can do is set your default 'file' layout in your theme's config.php under $THEME->layouts for 'login' as login.php and then customise that layout page using whatever PHP you need to create your own login page based on login/index.php. You can then change theme/yourtheme/layout/login.php the way you want it to work, being careful not to disturb too much of the original login layout.

You can certainly do quite a bit of this already just using CSS, as the login elements need to remain the same, don;t they, or are you planning on a totally new layout? If you are and you feel it an improvement then why not submit it for inclusion as an improvment using Moodle Tracker?

Cheers

Mary

In reply to Mary Evans

Re: Is there a way to create a layour with no main content

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ok...this is (based on) a custom theme written some time ago. I assume that the old token is still maintained for backward compatibility? I did believe the message and tried the new token but it didn't seem to work. Is it linked to some other change in the theme somewhere?

Anyway, no I don't think it's going to be any kind of improvement. It was just a client request who wanted some very specific layout and graphics. Definitely not a css tweak unfortunately. This is my bread and butter for better or worse - getting that 'corporate' look big grin

Thanks Mary !

EDIT:
Yes it does work... I'm just stupid !!

In reply to Howard Miller

Re: Is there a way to create a layour with no main content

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

Howard, you are beginning to sound like a stubborn Scotsman.  Of course you can add images and whatever in a customised login.php layout. That's what I do, for any layout I want to style, for that matter. This way you are not restricted to the normal layout as you would find in general.php. The layout could in actual fact be any style you want. You just need to place the main content output code whereever you want it to show up in your page. You could just add a div call it what you want, and make that section where the login form would be output and the rest of the page could look like whatever you want it to look like.

In reply to Mary Evans

Re: Is there a way to create a layour with no main content

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yep - I get it. That's what I'm doing except that the 'standard' code for the login page doesn't work for me (I need the form to be subtantially different), until Tim jumped in and made me think I should do it the "right" way.... sigh....

I only sound like a stubborn Scotsman. I'm actually a stubborn Yorkshireman who has lived in Scotland for 27 years. And that's very stubborn indeed tongueout

In reply to Howard Miller

Re: Is there a way to create a layour with no main content

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The only non-mad way to solve this is

  1. change login/index.php so that it does use a renderer, and submit that change to Moodle for integration.
  2. then, in your custom theme, you can override that renderer to do whatever you like.
Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Is there a way to create a layour with no main content

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hmmm....

I suppose the very worst that I can end up with is a custom patch for login.


It'll do me good.... I'm on it smile