[Solved] Adding Specific Custom Menus via Theme

[Solved] Adding Specific Custom Menus via Theme

by Brendan Lalor -
Number of replies: 6

Within my state college system, we have specific custom menus shared by all and only those who adopt our "Castleton theme" (it's based on More). So it would be nice if we could just add those menu items to the Castleton theme. I would love to override 'custommenuitems' using code in the Castleton theme, so that these links would be rendered in the custom menu theme-wide. 

Is there a procedure for adding a theme-based override of the 'custommenuitems' array? 

Or a model of the PHP for this? (I have seen lots of models of PHP for adding courses or categories as extensions of the custom menu. But those don't show me how to do the simpler thing I need to do - add a specific set of institutional urls to the menu.)

Thanks for any pointers!

(Edited by Gareth J Barnard - original submission Tuesday, 18 November 2014, 4:28 AM) - Added [Solved]  to title.

Average of ratings: -
In reply to Brendan Lalor

Re: Adding Specific Custom Menus via Theme

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Brendan,

I have done this sort of thing for a client in the past, so would do the same for you if you paid me.

Kind regards,

Gareth

In reply to Brendan Lalor

Re: Adding Specific Custom Menus via Theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
In reply to Richard Oelmann

Re: Adding Specific Custom Menus via Theme

by Brendan Lalor -

Thank you, Richard; that is a helpful tutorial. 

My purpose is even simpler, as I do not need to make a textarea for links available on a theme admin page. I would prefer directly to insert the 'custommenuitems' array in settings.php, or wherever it makes sense to do so. 

No discovering such a more direct solution, I will certainly spend some time figuring out how the code in your linked tutorial can serve the purpose. (My attempt to use it shut down my theme; so it's not that simple for me.) 

Thanks, and still looking for how to override 'custommenuitems' by injecting my own array. 

 ~Brendan 

In reply to Richard Oelmann

Re: Adding Specific Custom Menus via Theme

by Brendan Lalor -

Richard, 

Following the instructions via your link worked!: 

  • It adds a custommenuitems textarea to the theme's own settings. 
  • I was able to set my existing custommenuitems array as the default text. 

Many, many  thanks. 

~Brendan 

In reply to Brendan Lalor

Re: Adding Specific Custom Menus via Theme

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

I hope you did not add the renderer as that has nothing to do with adding the extra menu. It is just that the person who wrote the tutorial liked that particular menu design which needed a renderer. BootstrapBase has its own menu renderer...so should work ok.

In reply to Mary Evans

Re: Adding Specific Custom Menus via Theme

by Brendan Lalor -

Thanks, Mary. I skipped that step, because, as you indicate, we've already got renderer.php in the theme (which we cloned from More).