Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 403]

(no description)

File Size: 193 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

primary:: (4 methods):
  initialise()
  get_site_admin_node()
  set_active_node()
  search_and_set_active_node()


Class: primary  - X-Ref

Class primary.

The primary navigation view is a combination of few components - navigation, output->navbar,

initialise()   X-Ref
Initialise the primary navigation node


get_site_admin_node()   X-Ref
Get the site admin node if available.

return: navigation_node|null

set_active_node()   X-Ref
Find and set the active node. Initially searches based on URL/explicitly set active node.
If nothing is found, it checks the following:
- If the node is a site page, set 'Home' as active
- If within a course context, set 'My courses' as active
- If within a course category context, set 'Site Admin' (if available) else set 'Home'
- Else if available set site admin as active
- Fallback, set 'Home' as active


search_and_set_active_node(navigation_node $node,array &$actionnodes = [])   X-Ref
Searches all children for the matching active node

This method recursively traverse through the node tree to
find the node to activate/highlight:
1. If the user had set primary node key to highlight, it
tries to match this key with the node(s). Hence it would
travel all the nodes.
2. If no primary key is provided by the dev, then it would
check for the active node set in the tree.

return: navigation_node|null
param: navigation_node $node
param: array $actionnodes navigation nodes array to set active and inactive.