Posts made by Urs Hunkler

Picture of Core developers

With Moodle 2.0 blocks I have been working more intensive lately and I love how flexible and solid the block implementation works.

Overriding renderers, creating new block types to present content in different and special ways is relatively easy and just works. No surprises so far.

We can think about presenting Moodle content on the pages quite different in 2.0 and create pages needed or demanded from clients a lot more flexible and much closer to their needs.

Some examples will be shown in the near future on moodle.de.

Picture of Core developers

I ask you and all developers responsible for the "mymoodle" and the "user profile" page here related to the actual "blocks in the center of the page" question.

When I first saw how the center block region for those two pages in Moodle core are implemented I wondered why the blocks are implemented in this "hacky" way?

We have the layout files for the 'mydashboard' and for 'mypublic' page. From my understanding the definition for the 'content' region belongs in these layout files and not into page code.

The hack to create the region in page code breaks the overall concept and creates disadvantages. One is that the close relation in the theme between the layout files - the page structure - and the CSS - the page formatting - is broken. The other is that the principle that page code delivers the content and theme designers decide following client needs where the blocks are placed via region placement in the layout file is ignored.

A decision and a clear commitment to the Moodle 2.0 rules for developers and theme designers would make much sense and would help to keep the new structure clean and consequently implemented within Moodle. What do you and some of the core developers (Martin, Petr, Sam ...) think?

Picture of Core developers

Tim described the solution from a developer point of view. Tim's example creates a hack. But when you read the Moodle documentation you will learn that it is strongly recommended not to hack core files.

With Moodle 2.0 we have a non hacking way to place blocks on Moodle pages in the middle page area of the front page or many other pages. In the theme you add 'content' to the regions for the frontage in the theme config.php. Then in the layout file "frontpage.php" you check for blocks in that region and ´echo $OUTPUT->blocks_for_region('content')´ in the same manner as it's done for the other regions on that page. Easy too and no hacks needed - no problems with updates etc.

And to go the "official" way in the themes has the big advantage that the change is close to all the CSS you might also add to make the block look good in the content area. The area is wider than the side columns, you may want the header to display different, you may want to hide the buttons for docking and the "minus" icon for collapsing the content etc. All these changes make more sense in the theme than in any other place.

Picture of Core developers

I created the Moodle Tracker issue MDL-25690 and gave the "feature request" a "Major" priority because for more complex themes a flexible directory structure is essential.

Sam, any new insights from your side?

Everybody who agrees may vote for the issue.