Activity Settings Navigation Block

Activity Settings Navigation Block

by Amy Stewart -
Number of replies: 2

I have created a module and have used the <modulename>_extend_settings_navigation() function to add links to a few pages that will allow me to customize the module.  The pseudocode follows:

function <module>_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $<module>subnode=null) {
    global $PAGE;
    if(!has_capability('mod/<module>:edit', context_course::instance($PAGE->course->id))) {
        return;
    }
    
    $first_url = new moodle_url('/mod/<module>/first_page.php', array('id'=>$PAGE->cm->id));
    $node = $<module>node->add('First Page', $first_url, navigation_node::TYPE_SETTING);
    $second_url = new moodle_url('/mod/<module>/second_page.php', array('id'=>$PAGE->cm->id));
    $node = $<module>node->add('Second Page', $second_url, navigation_node::TYPE_SETTING);
    $third_url = new moodle_url('/mod/<module>/third_page.php', array('id'=>$PAGE->cm->id));
    $node = $<module>node->add('Third Page', $third_url, navigation_node::TYPE_SETTING);
}

When I click on the first node, it displays the page correctly, and the entry in the navigation node gets highlighted correctly (text is bold), however, if I click on the second node, the page displays correctly, but it highlights the first node.  Always.  It will never highlight any node below the first node.  

This isn't a terrible situation, however, it does look confusing to someone who is editing the module settings.  Any idea how to get the correct node to highlight in the navigation menu?

Average of ratings: -
In reply to Amy Stewart

Re: Activity Settings Navigation Block

by Amy Stewart -

One other thing to note about this strange behavior - when I click the page button, it always takes me to the URL of the first node.  Is there something I need to specify to 'finish' the addition of these nodes?

Thanks!

In reply to Amy Stewart

Re: Activity Settings Navigation Block

by Amy Stewart -

I figured it had to be something easy.  $PAGE->set_url was set to the wrong URL.  Glad it was an easy fix.