Themes

 
 
Picture of Dan Olson
Help modifying Clean theme into two-column format
 

I'm on Moodle 2.5.1 and have created a clone of the Clean theme which I am now trying to customize. Our preferred layout is 2-columns with blocks on the right, so I have added the following to our theme's config.php file: 

'course' => array(
    'file' => 'columns2.php',
    'regions' => array('side-post'),
    'defaultregion' => 'side-post',
),

and on... and on... for each instance where we want the 2-column format. But unfortunately this doesn't change any of the layouts, which are all still pulled from the bootstrapbase config.php. 

I suspect I am missing a step (or two), so any help would be appreciated. 

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Dan,

Ok, you are not doing anything wrong.  It is just that with a two column format and only side-post the blocks are still on the left.  Confused?  I was when I implemented MDL-40065.  I wanted 'pre' and 'post' to be left and right respectively as this matched with the definition of the words with a reversal logic for RTL languages.  But in Moodle, 'side-pre' and 'side-post' are more 'primary' and 'secondary' block areas that in LTR are on the left and RTL on the right.  And in certain situations blocks in 'side-post' will appear in 'side-pre' when 'side-post' does not exist.

The solution is to change the actual layout of columns2.php such that the block area is rendered on the right and not the left.

Cheers,

Gareth

 
Average of ratings: -
It's only an avatar...
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

If that is the case then this needs fixing. Are you sure that happens Gareth? I haven't tested it but will do so now.

Mary

 
Average of ratings: -
It's only an avatar...
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

I can only say...what a complete and utter mess we have managed to make with this theme since there is NO prevision for side-post only.

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Mary,

I think 'side-post' is supported but it will always be on the left in LTR and right in RTL.  This is what I was 'told' to do on MDL-40065 to get it past integration despite the conceptual definition of 'pre' and 'post' - as you will remember from reading the comments (and attached images) I disagreed at the time and still do - but have no choice in the matter.

In the mean time, I kept the fully working version of the layout file, so Dan, if you wish to try using https://github.com/gjb2048/moodle/blob/wip-MDL-40065-m25_3/theme/clean/layout/columns2.php - then it should work with only the 'config.php' changes you have made already.

Cheers,

Gareth

 
Average of ratings: -
It's only an avatar...
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Gareth,

Yes I do remember, but as I recall the conversations/diagrams were all about dir-rtl and the concept of where on the page (left or right) the blocks needed to be when language dictated.  And in that sense alone the page works as expected, but, and this is the problem we face now, it should not have been based on direction alone.

For example:

side-pre-only will display as a side-post-only when DIR-RTL

but there is no provision for the reverse

so there should be an alternative setting in span3 to pull-right depending if its side-post-only which will cancel out the pull-right in span9 when dir-ltr.

Anyway I need to test this out as it is slightly more complex than the standard themes I am used to.

Cheers

Mary

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Mary,

The code I posted should work.

To avoid confusion as I've lost the plot with the different meanings, can I clearly state that the logic I had planned worked to solve both the 'pre' and 'post' concepts and then the 'LTR' and 'RTL' concept.  Therefore being with 'pre' being a left concept and 'post' being a right concept in LTR and vice versa for RTL.  So:

In LTR:

side-pre is always on the left.

side-post is always on the right.

In RTL:

side-pre is always on the right.

side-post is always on the left.

Perfect symmetrical logic without losing the intent of what the theme designer intends.

Cheers,

Gareth

 
Average of ratings: -
Picture of Dan Olson
Re: Help modifying Clean theme into two-column format
 

Hi Mary and Gareth,

Thank you both for taking a look. Seems I've hit on an interesting problem. 

Gareth -- I swapped out your columns2.php code in my theme but unfortunately I have hit on two new problems. I'll try to keep this simple:

1) I noticed moodle is still picking up the layouts from the bootstrapbase config file rather than from my theme's config file. Does the problem have something to do with the way in which the Clean theme (and my clone) needs to override the renderer?  I am not that familiar with the way the renderers work, so this is just a guess. 

2) I tested #1 above by modifying the bootstrapbase config file and columns2.php file just to see if it would work. Those modifications did make changes to the site, but in so doing I received the following error: "Coding error detected, it must be fixed by a programmer: Trying to reference an unknown block region side-pre," which apparently is a known issue with Bootstrap?

Yes, I purged all caches along the way but that didn't help. Thoughts?

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Dan,

I've no idea why the new file is not being picked up - the renderer override should not be an issue, but to be sure, please attach the config.php file you are using - the clean replacement one.  The unknown 'side-pre' could be a misconfiguration of the config.php file - could you turn on developer level debugging and post a stack trace please?  Purge all caches only affects CSS and JS, PHP is not affected.

Gareth

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Also Dan, could you zip up your modified theme and put it somewhere to check the structure / folders etc.?

 
Average of ratings: -
Picture of Dan Olson
Re: Help modifying Clean theme into two-column format
 

Sure...

New theme config file attached.

Here's the stack trace on the coding error w/ bootstrapbase (modified config.php to columns2 and modified the columns2.php in layout):

Debug info: 
Error code: codingerror
Stack trace:
  • line 884 of /lib/blocklib.php: coding_exception thrown
  • line 984 of /lib/blocklib.php: call to block_manager->check_region_is_known()
  • line 997 of /lib/blocklib.php: call to block_manager->ensure_instances_exist()
  • line 315 of /lib/blocklib.php: call to block_manager->ensure_content_created()
  • line 1232 of /lib/outputrenderers.php: call to block_manager->get_content_for_region()
  • line 3053 of /lib/outputrenderers.php: call to core_renderer->blocks_for_region()
  • line 80 of /theme/clean/layout/columns2.php: call to core_renderer->blocks()
  • line 847 of /lib/outputrenderers.php: call to include()
  • line 777 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line ? of unknownfile: call to core_renderer->header()
  • line 1479 of /lib/setuplib.php: call to call_user_func_array()
  • line 79 of /mod/page/view.php: call to bootstrap_renderer->__call()
  • line 79 of /mod/page/view.php: call to bootstrap_renderer->header()

 

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Thanks Dan, ok, the stack trace shows the issue in the 'clean' theme folder and not down in 'bootstrapbase'.  But I see from the config.php file that your theme is called 'learningmarkets' so 'clean' should be nowhere to be seen.  Therefore, can I ask some silly questions:

  1. Is the new theme's containing folder called 'learningmarkets'?
  2. Have you changed the theme to 'learningmarkets' in the theme selector?

In the stack trace the faulty line is 80 calling blocks, this is the wrong line if the file was the replacement https://github.com/gjb2048/moodle/blob/wip-MDL-40065-m25_3/theme/clean/layout/columns2.php but not if using the distributed 'clean' theme version.  Therefore 'learningmarkets' is not being used because possibly 1 and / or 2.

The error is because the standard columns2.php has a hard coded 'side-pre', therefore the 'regions' needs to define it even if it is not the default - Mary, do you think this was the intent on MDL-40065 with a two column layout that 'side-pre' always had to exist?  But, Dan, I don't think that's completely relevant to you using the replacement columns2.php file as it should work without 'side-pre' - we just need to get the theme working.

Gareth

P.S. The config.php file looks fine.

 
Average of ratings: -
Picture of Dan Olson
Re: Help modifying Clean theme into two-column format
 

Ack! Clearly not a silly question at all as that is exactly what happened! Not sure if it was through my ignorance or if upon breaking my theme along the way moodle somehow dropped my theme, but the 'clean' theme was, in fact, selected. 

Just to be safe I completely uninstalled and reinstalled my theme -- and then (ahem) *selected* it -- and then fired up your new columns2.php file and it all worked just fine. We have two columns, blocks on the right, and we're off to the races.  (Out of curiosity I did test it once with the original columns2.php file and it did throw that same error.) 

Thanks for the help, Gareth, and sorry for the silly distraction. 

Dan

 

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Dan,

No problem.  This might be another positive 'blue touch paper' lighting event smile

Cheers,

Gareth

P.S. You might need to do some non-structural tinkering as the code is over a month old and there have been some changes since then.  Just do a difference on the files to get an idea.

 
Average of ratings: -
It's only an avatar...
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Gareth,

What made you change that duel layout? Was it because of all the confusion with pre and post and rtl?

I have just spent some time creating a new layout and called it columns2rt.php

See attached.

This seems to work OK.

Thoughts?

Cheers

Mary

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Mary,

It was Sam's comment https://tracker.moodle.org/browse/MDL-40065?focusedCommentId=230075&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230075 and below.  I had no choice!

'columns2rt.php' gets a little of the way but should break when used with 'side-pre' as 'side-post' is hard coded.  Ok...

There is a two stage logic to deal with (I cannot believe I'm still having to explain it!!!)....

  1. If there is a 'side-pre' then put the blocks on the left otherwise must be 'side-post' then put the blocks on the right.  That is stage one.
  2. Stage two is if we are using an RTL language, if so, then swap the side decision made in 1.

So, to repeat in case it was missed the first time...

  1. Test if using 'side-pre' to determine the side that the blocks should go on.
  2. Test if using RTL, if so, swap side decision made in 1.

This is all based upon the perceived notion that 'pre' means before and 'post' means after - which until I worked with this I assumed was fact.  And secondly that in LTR the direction is from the left of the page to the right of the page and in RTL from the right to the left, so logically with LTR 'side-pre' is on the left and 'side-post' is on the right and with RTL, 'side-pre' is on the right and 'side-post' is on the left.  I am NOT confused about this, it's just does not seem to be getting through as people keep telling me that I'm wrong when in fact they are missing the point that theme's need to support the ability to put blocks where they are desired and that 'pre' means before and 'post' means after.  If this is not the case, then change them to something more meaningful before every theme designer goes nuts trying to solve the problem like supporting Internet Explorer.

I'm sorry if I'm sounding fed up, but that is the case.  This is simple logic with only four states!  How hard can that be to understand?

Gareth

P.S. If 'side-pre' and 'side-post' are renamed to 'primary' and 'secondary' then we would loose the ability to conceptually place things where we wanted them to be.  Lets leave it as is and provide the best possible API to theme designers so they can get on with creating wonderful stuff.

P.P.S.  Even if I'm wrong and 'side-pre' and 'side-post' are just primary and secondary block locations then use my code as at least it gives the option of facilitating a switch in sides of the blocks just by changing the values in the 'config.php' file.

 
Average of ratings: -
It's only an avatar...
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

The file I uploaded was for side-post-only. And as such is, as you quite rightly say,  hardcoded for side-post. The idea would be to HAVE columns2.php AS WELL AS columns2lt.php.

You sound a lot more than a 'bit fed up' I would be too! in fact I thought that the duel layout was spot on and really wondered why you had changed it. I had forgotten about Sam's comments. 

I think he has it wrong so have set up MDL-41055 to add a new layout for side-post-only to Bootstrapbase.

Cheers

Mary

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Dear Mary,

No worries and I see.  Your idea sounds like a plan.

Thank you for setting up MDL-41055 - I'll continue commenting on there.

Indeed I am more than a bit fed up.  So therefore the Shoelace theme being independent implements what I think should be the solution.

Cheers,

Gareth

 
Average of ratings: -
Brian
Re: Help modifying Clean theme into two-column format
Group Particularly helpful Moodlers

It was interesting to move my Bootstrap theme up to 2.6 (I guess I had sat on the 2.4x code too long).

The original code in earlier versions supported side-pre and side-post by detecting the $THEME->layout parameters, but the new bootstrapbase seems to have done away with them, and has hard-wired for side-pre.

It did seem more user friendly to be able to change the layout from side-pre to side-post by editing config.php than by forcing the admin to copy the columns2.php to columns2rt.php and edit the settings to correct the border css classes.

I do understand the need for both RTL and LTR as well as side-pre and side-post "redirects" when content defaults to a side which does not currently exist in that layout, but other themes seem to handle this quite well.

I don't want to stir things up though - is it OK if I raise another tracker to correct how I believe bootstrapbase should work?  The code in 2.4.3 almost worked, we just needed content destined for side-pre to appear on side-post when that was the only layout available.

Thoughts?

 

 
Average of ratings: -
Gareth J Barnard
Re: Help modifying Clean theme into two-column format
Group DevelopersGroup Particularly helpful Moodlers

Hi Brian,

You can try!  But please review the logic as posted on the attached files of MDL-40065 first.  And please look at how my Shoelace theme handles things.

Also examine the current code very carefully.  There is a complicated switching mechanism going on, so even if the parameter in RTL is 'side-post' it ends up as 'side-pre'.

Given the way that MDL-40065 progressed the first time there needs to be a solid well substantiated argument.  And even that might not work!

Cheers,

Gareth

 
Average of ratings: -