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

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 吐舌頭

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
評比平均分數: -