Custom menu at the theme level

Custom menu at the theme level

by Frederic Nevers -
Number of replies: 4

Hi, 

How should I go about adding a custom menu to my theme, which would be only visible to users who have selected that particular theme? I guess it could be described as a 'theme specific custom menu', which admins can manage in theme settings. I manage a site with multiple themes (variations of a simple theme I have created), all of which need to display different menus.

The 'theme specific custom menu' would need to go alongside the default Moodle custom menu, and ideally follow the same syntax for admins to add their links (it needs to handle multiple languages). Can I somehow use or extend the render_custom_menu function?

Currently I have hardcoded links in my core_renderer file and works fine but it means I am the bottleneck in the system (admins need to email me the links to be placed in the themes).

Any ideas or examples welcome. 

Cheers, 

Fred

Average of ratings: -
In reply to Frederic Nevers

Re: Custom menu at the theme level

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

There is a way to do this I have this in Morecandy theme, but is set as a Frontpage only, the normal one is used after login. 

Dan Marsden figured this out and was added into core renderer in Moodle.2.2 I think.

Checkout Morecandy here...

ill list the code you need in another post comment.

https://github.com/lazydaisy/moodle-theme_morecandy.git

Cheers

Mary

In reply to Mary Evans

Re: Custom menu at the theme level

by Frederic Nevers -
Hi Mary, 


A quick follow-up message to let you know I managed to implement what I wanted to achieve, though the requirements changed as I was working on it (don't they always?!). Again, thank you for pointing me in the right direction. 

I ended up using code from the 'Adaptable' theme, more specifically anything related to the tools_menu function in case anyone wants to achieve the same. It's not for the faint-hearted but it's doable (I'm no coding wizard). You'll need to copy the lib.php file, settings files (the header_navbar_menu.php file), necessary functions from the renderers.php file, bits from admin_confightmleditor.php and fiddle with your theme config.php and settings.php files. 

I'm happy to help if anyone is stuck with a similar issue to the one described in the opening post, just reply to this thread and I'll share what I can. 

Cheers, 

Fred

In reply to Mary Evans

Re: Custom menu at the theme level

by Frederic Nevers -

Hi Mary, 

Thank you very much for the pointers! I'll try and integrate it to my themes in the next few days. 

Cheers, 

Fred