Newb question : logic between $OUTPUT and layout files

Newb question : logic between $OUTPUT and layout files

Simon Vartdən -
Number of replies: 0

Hi all,

I'm starting working on a new custom theme. To not get lost, I had cloned Essential.

As I understand, Moodle core is mapping, inside theme/config.php, pagelayout (as a string stored in $PAGE->pagelayout) to a layout php file. As is 'frontpage' => 'layout/frontage.php'

So far, so good.

Then I want to change the header.

I have different tools which somehow, for someone as new in Moodle internals as me, feels superposed.

Like : when to use a function in the renderer ( using $OUTPUT->myfunction() ) and when to use directly layout file header.php file (or any other php file that I would like to include) with my HTML code inside it. And, maybe, I could even use blocks for this.

So what is the logic which could tell me : for this purpose (create a new header in my page), I will use a function in a rendering function by extending the core renderer, or I will just add my HTML fragment in the header.php file, or I will create a block that will output HTML in my page ? 

(Also, as a sidenote, I see that in the layout file, we are mixing php and HTML in a regular PHP fashion, and in the renderer object, I will tend to use html_writer function, which produce HTML too - and this is also a logic I do not fully understand).

Could anyone that has this logic in mind could help me understand how to make the "right" decisions - in a functionnal way, but also in the way I should produce Moodle code ?

Thanks !

Orta qiymət: -