Nested Navigation for Boost Theme Moodle 3.2

Nested Navigation for Boost Theme Moodle 3.2

by Antoine Briffa -
Number of replies: 3

Hi,

I have a local plugin and I am trying to add a link to the Site Home navigation menu.


So it becomes like My Courses

Something like:

Site Home

- My Media


Now in the other themes (Standard) it works fine, however in the new Boost Theme nothing is showing up.


This is the code:

function local_mymedia_extend_navigation($navigation) {
global $USER;

$node_home = $navigation->get('home');
$mymedia = get_string('nav_mymedia', 'local_mymedia');
$mymediaNode = $node_home->add($mymedia, new moodle_url('/local/mymedia/mymedia.php'), navigation_node::NODETYPE_LEAF, $mymedia, 'mymedia');
}
The above code works for the standard theme, but not for the boost theme.


I tried some other things like adding:

$mymediaNode->set_parent($node_home);
$mymediaNode->indent = 1;
and nothing shows still.


Also adding:

$mymediaNode->showinflatnavigation = true;
will make the link show, however not under Site home, but as a link on its own.


Any help on how to add a child link under Site Home for same behaviour as My Courses?


Thanks


Average of ratings: -
In reply to Antoine Briffa

Re: Nested Navigation for Boost Theme Moodle 3.2

by Yuriy Hetmanskiy -

Hi!

I have an 'accident' when local_<myplugin>_extend_navigation function in /local/<myplugin>/lib.php didn't work until I purged the all cache. This peculiarity may be related to all types callback function like this! Moreover there aren't any info about cache in such articles:

https://docs.moodle.org/dev/Navigation_API#Local_Pluginshttps://docs.moodle.org/dev/Local_plugins#Local_admin_menu_items_and_settings

P.S. I'm using 3.3.x version now with Boost theme!

In reply to Yuriy Hetmanskiy

Re: Nested Navigation for Boost Theme Moodle 3.2

by Mary Evans -

Hi, 

Are you asking for help or is this your reply to the previous questions?

Thanks

Mary

In reply to Mary Evans

Re: Nested Navigation for Boost Theme Moodle 3.2

by Yuriy Hetmanskiy -

Hi!

No,no! That was no asking for help, I've just remarked about the nuance of cache related to Navigation API! Don't forget about cache! 

So in general the code above is correct. And my code (file /loca/smart/lib.php) for instance was:

function local_smart_extend_navigation($navigation) {
$node = navigation_node::create(get_string('mycohorts', 'local_smart'),
new moodle_url('/blocks/cohortnews/cohorts.php', ['scope'=>'my']),
navigation_node::NODETYPE_LEAF,
'mycohorts',
'mycohorts',
new pix_icon('t/addcontact', 'my')
);
$node->showinflatnavigation = true;
$navigation->add_node($node); //....
Thanx!

Yurii