General developer forum

How to view the "components/properties" of the $OUTPUT

 
Picture of Samuli Karevaara
How to view the "components/properties" of the $OUTPUT
Core developersParticularly helpful MoodlersTranslators

(Using M3.5) I've been trying to read the documentation and also the code, but there is too much "magic" going on for me to follow. Boost theme uses mustache templates, and then the mustache template is given "output = $OUTPUT" (and some other stuff). The mustache template then "prints" out for example "output.standard_top_of_body_html" and "output.main_content".

1) How can I find out what these properties of the "output" object are? Where are they defined?

2) I tried var_dump:in $OUTPUT, but it doesn't show "main_content" for example. Where is it defined?

3) I wanted to add stuff to the "main_content", where do I do that? The mustache template only has the "all or nothing" approach to the main_content, there is no granularity?

 
Average of ratings: -
Picture of Darko Miletić
Re: How to view the "components/properties" of the $OUTPUT
Core developersParticularly helpful Moodlers

$OUTPUT is a global instance of one of the core renderers (for example core_renderer). For renderers check the docs

https://docs.moodle.org/dev/Output_API

https://docs.moodle.org/dev/Output_renderers

Implementation can be located here [moodledir]/lib/outputrenderers.php .

I also strongly suggest to use propper IDE for development that permits quick browsing of the source code like Eclipse PDT, NetBeans or PHPStorm.

The only way to fully modify global presentation of Moodle is to write your own theme which is the place where you can implement whatever is required.

What are you trying to accomplish exactly and does that something applies to all or just some pages in moodle?


 
Average of ratings: -
Picture of Samuli Karevaara
Re: How to view the "components/properties" of the $OUTPUT
Core developersParticularly helpful MoodlersTranslators

Thanks Darko! I did browse through those documentation pages, but couldn't find a list of output methods/properties. Also did stumble upon the outputrenderers.php but there was something about the main_content implementation that I didn't fully grasp yet. The comment on the main_content method does mention that "This is an unfortunate hack." wink

I'm building a theme of my own. Using Visual Studio Code with PHP Intelephense. But yes, I'm not fluent in jumping through the code with that, it doesn't seem to get the class hierarchies very well. I get a lot of "No definition found for..." errors when trying to jump to a method definition. Maybe my workspace is too narrow, have to google more on that.

Anyhoo, I was trying to add direct "create a new account" form fields to the login screen, but it seems that the theme doesn't have enough granularity over the login form html?


 
Average of ratings: -
Picture of Darko Miletić
Re: How to view the "components/properties" of the $OUTPUT
Core developersParticularly helpful Moodlers

But that functionality already exists.

See

https://docs.moodle.org/35/en/Email-based_self-registration

And if that does not exactly do what you want you need to create clone of that plugin and add whatever may be missing.

 
Average of ratings: -
Picture of Samuli Karevaara
Re: How to view the "components/properties" of the $OUTPUT
Core developersParticularly helpful MoodlersTranslators

Thanks again! Ultimately my goal is to have a better understanding about the limits of how to alter the core features of moodle without having to fork the git repo, i.e. purely with plugins. That's why I was interested in modifying directly whatever the "main_content" method of the core_renderer class produces, via a mustache template.

You are right that the "Create a new account" button is readily available, but I was testing if it would be plausible to create an super simplified "create new account" form directly to the login screen. This would mean that, for example, just a gotcha and an email address.

 
Average of ratings: -