Adding Navigation to: Settings -> Course Administration -> My Tool

Adding Navigation to: Settings -> Course Administration -> My Tool

by Andrew Normore -
Number of replies: 3

Hello again, 

I've had success adding navigation else where, but here:

sad

When I do a var_dump ($PAGE->navigation) to see where I might stick it, my server crashes. Moodle 2.3.

Any one point me in the right direction? 

Average of ratings: -
In reply to Andrew Normore

Re: Adding Navigation to: Settings -> Course Administration -> My Tool

by Sam Hemelryk -
Hi Andrew,

Straight up, there's no easy way to do this presently.
Admin tools aren't given hooks within the navigation and settings so a core change would be required.

Interestingly enough a request for such an improvement was created not too long ago. MDL-36585.
Mark who created the issue also provided a patch that is spot on.
However the question is whether or not allowing admin tools to extend the course settings is in line with what the admin tool plugin was designed for.
Have a read of the issue, really it is just a case of deciding if we want to allow it.
I should point out as an improvement it would land in the next major release only, so still not an immediate solution.
If you really want to get something into the nav at the moment you could create a local plugin to allow it (either to add the nodes you want or to make the callback in Mark's patch). Not a great solution perhaps but it would work.

As for the var_dump thing, the navigation node contains references both to all of its children as well as its parents.
I've found in many situations if you try to call var_dump, or print_r on it things crash of you get empty pages.
To get around this I have a couple of functions in a central file that I include within the config.php of all my development Moodle sites.
I've attached just the required function in a php file to this post.

That way if I need to inspect the navigation structure I can simple call debug_navigation().

Hope that all helps.
Sam
Average of ratings:Useful (1)
In reply to Sam Hemelryk

Re: Adding Navigation to: Settings -> Course Administration -> My Tool

by Andrew Normore -

You sir, are awesome. Thanks for the information, I'll build a work around.

In reply to Sam Hemelryk

Re: Adding Navigation to: Settings -> Course Administration -> My Tool

by Rosario Carcò -

As Sam suggests, I have managed to introduce my UPLOAD USER AND COURSES link into the Admin-Menu in 1.9 and also in 2.3, now using a simple /local/uploaduserandcoruses/ plugin. You can have a look in to my code to see how to do this. My link/hook appears just below the built in USERS->ACCOUNTS->upload users menu in the site-Administration.

HTH, Rosario