Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 197 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.

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