How to remove "Site Pages" menu item in Moodle 3 using your own theme

How to remove "Site Pages" menu item in Moodle 3 using your own theme

by James B -
Number of replies: 2
I'm writing this up in A) the hope it will be useful to others and B) someone will correct any mistakes I've made tongueout

Firstly, you need your own theme. In this theme, create the file classes/core_renderer.php

Add:


include_once($CFG->dirroot . "/blocks/navigation/renderer.php");


class theme_THEMENAME_block_navigation_renderer extends block_navigation_renderer {

    protected function navigation_node($items, $attrs = array(), $expansionlimit = null, array $options = array(), $depth = 1)

    {

        if (is_array($items) && count($items) > 0) {

            $items[0]->children->remove('1', 20);

        }

        return parent::navigation_node(

            $items,

            $attrs,

            $expansionlimit,

            $options,

            $depth);

    }

}



(Note the 20 in ->remove('1', 20) is required. I think this is a bug and you should be able to pass null here - this is discussed at https://tracker.moodle.org/browse/MDL-53383 )

Do post with any improvements! Thanks
Average of ratings: -
In reply to James B

Re: How to remove "Site Pages" menu item in Moodle 3 using your own theme

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moving to Themes forum...