Local plugin, Make the custom menu active on clicking the menu item.

Local plugin, Make the custom menu active on clicking the menu item.

by Bhargava S -
Number of replies: 0

I am new to moodle. Using Moodle 2.8.5. Created a local plugin setmotd and was able to add a new menu item to Site Administration for the plugin. Now I wan to make the new custom menu item active on clicking.

Please help. Code Used :

    function local_setmotd_extends_settings_navigation(settings_navigation $settingsnav, context $context)
    {
        global $CFG, $PAGE;
     
        /*
        // Only let users with the appropriate capability see this settings item.
        if( ! has_capability('local/setmotd:view', $context) )
        {
            return;
        }
        */
        $settingnode = $settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
        if( $settingnode )
        {
            $setMotdMenuLbl = get_string( 'menutitle','local_setmotd' );
            $setMotdUrl = new moodle_url('/local/setmotd/set_motd.php');

            $setMotdAdminNode = navigation_node::create(
                $setMotdMenuLbl,
                $setMotdUrl,
                navigation_node::NODETYPE_LEAF);

            file_put_contents('f:\chinanovation\my-logs\my-log.txt',"MA#".$PAGE->url."#".URL_MATCH_BASE);
            if ($PAGE->url->compare($setMotdUrl, URL_MATCH_BASE)) {
                $setMotdAdminNode->make_active();
            }
            $settingnode->add_node($setMotdAdminNode);
        }
    }

Average of ratings: -