Themes

 
 
Picture of Urs Hunkler
Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Particularly helpful Moodlers

First of all I want to say that I like the new clean look in the layout files "columns1.php" etc. - "general.php" was quite sophisticated and not easy to understand.

2 questions about the layouts

  1. Why is there no frontage layout?
  2. Why is the HTML for empty page areas included into the page and hidden with CSS?

at 1. Why is there no frontage layout?

The frontage on most Moodle installations looks different from most other pages. With a frontpage layout several empty areas can be avoided.

at 2. Why is the HTML for empty page areas included into the page and some are hidden hidden with CSS when a layout-option is set?

For example the course header area is created and left empty in the page.

<div>
    <?php echo $OUTPUT->course_header(); ?>
</div>

The navbar area is completely created with the breacrumb and all and hidden with the help of the body class ".layout-option-nonavbar".

If the rendered page should be as lean as possible the approach to add HTML only to hide it with CSS does not make sense. Why has this approach been chosen?

The only reason I can imagine is to keep the areas for later use in the browser where some content may be rendered into the area with JavaScript? Or to show/hide it with media-queries?

 
Average of ratings: -
It's only an avatar...
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Urs,

How would you do this?

If it were up to me I would be making lots of layout files.

Mary

 
Average of ratings: -
Picture of Urs Hunkler
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Particularly helpful Moodlers

Mary, I would use for example a layout file like "frontpage.php" as in base wink Probably call it "columns3_front.php" or "columns2_front.php" or similar.

 
Average of ratings: -
Picture of Danny Wahl
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Particularly helpful Moodlers

I think most themes do something like

$courseheader = (!empty($OUTPUT->course_header));

if($courseheader) { echo $OUTPUT->course_header; }

but really, if the end result is just an empty div tag, well that's not the end of the world in terms of page "lightness".

Keeping multiple layout files that are 98% the same just gets annoying, that's why I only use 1 for all my themes and use logic to hand page-specific output.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Note that

html_writer::non_empty_tag('div', get_content(), array(...));

is a nice utility. I will only output the div if get_content() returns something other than a non-empty string.

 
Average of ratings: -
Picture of Urs Hunkler
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Particularly helpful Moodlers

Thank you everybody for your answers. Tim, "html_writer::non_empty_tag" I never had seen in use before and a search for "html_writer::non_empty_tag" in the Moodle 2.5 codebase brought up no result.

I had seen the changes in bootstrapbase/clean in the columnN.php layout files and noticed the changes to handle "empty" and also not empty page areas by hiding them with CSS (question 2 above). The question why the decision has been made to hide areas instead of not output it at all has not been answered yet. May Sam Hemelryk who worked on the implementation as I saw from his commits give some answers?

 
Average of ratings: -
Picture of Danny Wahl
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
 
Average of ratings:Useful (1)
It's only an avatar...
Re: Question about Moodle 2.5 new $OUTPUT methods and dealing with empty page areas
Group DevelopersGroup Documentation writersGroup Particularly helpful MoodlersGroup Testers

Hi Urs,

Gareth Barnard has been fixing two of the layouts, columns3.php and columns2.php these work much better now. They are a lot cleaner and simpler to understand.

You should be able to see them in https://github.com/moodle/moodle.git  ../theme/clean/layout

Cheers

Mary

 
Average of ratings: -