custommenuitems from theme setting and not the site custommenuitems

custommenuitems from theme setting and not the site custommenuitems

Jonathan Konrad -
回帖数:8

I am trying to have a course show a different custom menu than the whole site. I'm trying to do this by modifying a theme to display a theme custom menu instead of the site custom menu. This time I have started with the aardvark theme. First I opened up the settings.php file and added this;

$name = 'theme_aardvark/custommenuitems';
$title = get_string('custommenuitems', 'admin');
$description = get_string('configcustommenuitems', 'admin');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$settings->add($setting);


I then opened up the header.php file and changed this;

$custommenu = $OUTPUT->custom_menu();


for this;

$custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems);


It nearly worked. There is now an area where I can enter a custom menu in the theme settings for aardvark. When I load a course with that theme however, it first shows the menu items defined in the theme settings, but then keeps right on going and shows the menu items defined for the whole site. I'm so close. Can anyone tell me what modification I need to do to have ONLY the custom menu items from the theme settings display? Thanks.

I am using Moodle 2.6.x 




回复Jonathan Konrad

Re: custommenuitems from theme setting and not the site custommenuitems

Mary Evans -

Take a look at how I converted this theme to use the theme based custom menu

 https://github.com/lazydaisy/Moodle-Studio/tree/aaradyha/aaradyha/layout

The link shows all the layout files which need the extra setting.

Also depending on the version of Aardvark it could be you are missing some code in the layout.

You need these two lines...

https://github.com/lazydaisy/Moodle-Studio/blob/aaradyha/aaradyha/layout/general.php#L43-L44

And also thes lines...

https://github.com/lazydaisy/Moodle-Studio/blob/aaradyha/aaradyha/layout/general.php#L80-L82

Let me know how you get on

Cheers

Mary

回复Jonathan Konrad

Re: custommenuitems from theme setting and not the site custommenuitems

Mary Evans -

I've spent a bit of time with this and I am finding that does not work in Bootstrap theme, and I half suspect it is because the menu is different than the old style menu in Base theme, where this second menu originated.

I'm currently trying to track down where the problem is, and at present looks as though I may have to report this as a regression if the menu does not work in 2.7.

What a pain this is...

Mary



回复Jonathan Konrad

Re: custommenuitems from theme setting and not the site custommenuitems

Mary Evans -

The reason it's not working is becasue the renderer in Bootstrapbase is overriding the setting that allows this theme based custommenu.

So to fix that you can try adding this renderer found in my Tiny Bootstrap Project here...

https://github.com/lazydaisy/tiny-bootstrap-project/blob/master/renderers.php#L316-L405

I have attached a renderers.php to save you the bother of making one...you should find it works OK but may need to tweak the CSS...

Just add the renderers.php into the aardvark folder...

also check that the aardvark/config.php has this line still in it...

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

Cheers

Mary

回复Mary Evans

Re: custommenuitems from theme setting and not the site custommenuitems

Jonathan Konrad -

Wow, Thanks so much for working on this and finding me a solution. I do not have access to my server till later today. When I do, I will attempt to use your fix by adding the code and the renderers.php file. I will report back how it goes. Again, thank you so much for helping me with this.

回复Jonathan Konrad

Re: custommenuitems from theme setting and not the site custommenuitems

Mary Evans -

It was a pleasure really, as I was the one that promoted this menu after Dan Marsden added the fix to Moodle 2.3, it is so versatile and yet sad to think it might be lost if the bootstrapbase/renderers/core_renderer.php is not fixed! 伤心

回复Mary Evans

Re: custommenuitems from theme setting and not the site custommenuitems

Jonathan Konrad -

So much closer. This renderers.php file prevented the inclusion of the site menu custommenuitems. However, it changed the look of the navbar or breadcrumbs. I'm not sure who to change that back. Here are some screen shots of what I mean.

With the renderers.php file. Only the theme custommenuitems, but verticle navbar;


Without the renderers.php file. Shows both the custommenuitems, and a horizontal navbar


Thoughts on what to tweak next ? Thanks

回复Jonathan Konrad

Re: custommenuitems from theme setting and not the site custommenuitems

Mary Evans -

I'm in the process of fixing a bug in Bootstrapbase MDL-45507 that is causing this type of menu to fail. However there does appear to be a bug in the Aardvark theme which is making thing worse, so not sure what is happening there.  If I get time today I will be taking another look, as I had it working at one stage. But now it's not and I see the breadcrumb as you see it. How very odd.