Block or Change Custom Menu for a Course

Re: Block or Change Custom Menu for a Course

by Mary Evans -
Number of replies: 2
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

I'll make up a theme so you can test it...as you seem to have only half of it working.

The place you add the Menu items to are in the settings page for the theme, which is different that the theme settings page found at Site Administration > Appearance > Themes > Theme settings

- this is normally where you add the global menu items.

Whereas in a theme that has both the ordinary menu and the 'mysuperduperthememenu' (to give it a name)  you would need to add the extra menu to this location in your moodle site...

Site Administration > Appearance > Themes > MySuperDuperThemeMenu' which is just a link to the Custom settings page for that theme assuming of course the theme you are using is called MySuperduperThemeMenu.

Sorry if this does not make sense but it's all rushed as I don't have time to explain properly.

If no menu items are added in the customised theme (ie. MySuperDuperThemeMenu settings page) then the standard 'global' menu is used.

Is that clearer?

Let me know if that 2nd menu shows up?

Cheers

Mary

In reply to Mary Evans

Re: Block or Change Custom Menu for a Course

by Helen Moraes -

Hi,

I have some issues I hope you can help me with.

I followed each steps provided by Mary, but using Elegance theme, with a Elegantchild child theme (found in Moodle.org) I can't have a different custommenu on differet themes.

I followed these instructions too:

https://tracker.moodle.org/browse/MDL-31043

https://moodle.org/mod/forum/discuss.php?d=193738

 

Problems:

1) Elegantchild has its own settings.php.

If I add to it (where?) this lines afetr php opening tag nothing seems to happen, but of course it could depend on the fact that other steps are missing; if I put it inside the document (e.g. at line 56 or line 79) I get a blank page.

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

So, I deleted old settings.php for child theme and created a new one with only this:

<?php

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {

    // Theme overrides custom menu
    $name = 'theme_elegantchild/custommenuitems';
    $title = get_string('custommenuitems', 'admin');
    $description = get_string('configcustommenuitems', 'admin');
    $default = '';
    $setting = new admin_setting_configtextarea($name, $title, $description, $default);
    $settings->add($setting);
}

 

 

2) Assuming I have the settings.php above, I go forward and try with layout file. Elegantchild has no default.php file and no layout folder. If I create the folder and put a default.php in it (cloning from elegance theme, and changing

    theme_elegance_initialise_reader($PAGE);

    to

theme_elegantchild_initialise_reader($PAGE);

inside it (the only change I found), and then add 

$custommenu = $OUTPUT->custom_menu($PAGE->theme->settings->custommenuitems);
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

after the opening php tag, I get some strange message in the rendered page of the child theme, something like

[MAIN CONTENT GOES HERE - ZvJFRzKKnS]

and navigation buttons stop working. This is the only thing I can see from now.

One more thing, I tried also the MDL-31043 change (that is a little different, MAYBE, from Mary's), but Elegance default.php has no

$custommenu = $OUTPUT->custom_menu();

but a

    <div id="moodle-navbar" class="navbar-collapse collapse">
        <?php echo $OUTPUT->custom_menu(); ?>
        <?php echo $OUTPUT->user_menu(); ?>

so I don't know how to change it to make it look like

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

 

3) I tried to purge chaches, but after point 2) I can't browse site.

 

4) Mary wrote

Depending on where you want this menu to show you would need to add the file name to the $THEME->layouts found in the theme's config.php

Is this step I'm missing? I can't really figure out how to do this.

 

 

So, am I missing /doing wrong something? (I bet it's so!)

PS: I'm using Moodle 2.6.2. with Elegant / Elegantchild themes.

In reply to Mary Evans

Re: Block or Change Custom Menu for a Course

by Jonathan Konrad -

I'm trying again. I think I'm getting closer to understanding, but I've bumped in to a problem. When I put the code you indicate in my settings.php file in the theme I'm editing (Essential), my site administration fails to load (shows a very small, blank pop up box) and I cannot get in to anything under site administration. 

I read this page: https://tracker.moodle.org/browse/MDL-31043

It seems to provide very similar instructions. Following this yields the same result, a problem loading my site administration settings. That link also references changing something in outputrenderers.php . I'm not sure where that file is, or if I should replace something with the code given or add the code given.

I feel so close, I'd love to have a custom menu for a given theme that I could define in the theme settings page. I'd pay someone to do this small hack for me, but I do not know who! Thanks for any help you can give.

Average of ratings: Useful (1)