Custom menu class.  
 More...
|  | 
|  | __construct ($definition='', $currentlanguage=null) | 
|  | Creates the custom menu. 
 | 
|  | 
|  | add ($text, moodle_url $url=null, $title=null, $sort=null, $attributes=[]) | 
|  | Adds a custom menu item as a child of this node given its properties. 
 | 
|  | 
|  | export_for_template (renderer_base $output) | 
|  | Export this data so it can be used as the context for a mustache template. 
 | 
|  | 
|  | get_children () | 
|  | Sorts and returns the children for this item. 
 | 
|  | 
|  | get_parent () | 
|  | Gets the parent this child belong to. 
 | 
|  | 
|  | get_sort_order () | 
|  | Gets the sort order for this child. 
 | 
|  | 
|  | get_text () | 
|  | Returns the text for this item. 
 | 
|  | 
|  | get_title () | 
|  | Returns the title for this item. 
 | 
|  | 
|  | get_url () | 
|  | Returns the url for this item. 
 | 
|  | 
|  | has_children () | 
|  | Returns true if this item has any children. 
 | 
|  | 
|  | override_children (array $children) | 
|  | Overrides the children of this custom menu. 
 | 
|  | 
|  | remove_child (custom_menu_item $menuitem) | 
|  | Removes a custom menu item that is a child or descendant to the current menu. 
 | 
|  | 
|  | set_text ($text) | 
|  | Sets the text for the node. 
 | 
|  | 
|  | set_title ($title) | 
|  | Sets the title for the node. 
 | 
|  | 
|  | set_url (moodle_url $url) | 
|  | Sets the url for the node. 
 | 
|  | 
|  | sort () | 
|  | Sorts the children this item has. 
 | 
|  | 
|  | 
| array | $attributes = [] | 
|  | Array of other HTML attributes for the custom menu item. 
 | 
|  | 
| array | $children = array() | 
|  | A array in which to store children this item has. 
 | 
|  | 
| string | $currentlanguage = null | 
|  | The language we should render for, null disables multilang support. 
 | 
|  | 
| int | $lastsort = 0 | 
|  | A reference to the sort var of the last child that was added. 
 | 
|  | 
| custom_menu_item | $parent | 
|  | A reference to the parent for this item or NULL if it is a top level item. 
 | 
|  | 
| int | $sort | 
|  | A sort order for the item, not necessary if you order things in the CFG var. 
 | 
|  | 
| string | $text | 
|  | The text to show for the item. 
 | 
|  | 
| string | $title | 
|  | A title to apply to the item. 
 | 
|  | 
| moodle_url | $url | 
|  | The link to give the icon if it has no children. 
 | 
|  | 
Custom menu class. 
This class is used to operate a custom menu that can be rendered for the page. The custom menu is built using $CFG->custommenuitems and is a structured collection of custom_menu_item nodes that can be rendered by the core renderer.
To configure the custom menu: Settings: Administration > Appearance > Themes > Theme settings
- Copyright
- 2010 Sam Hemelryk 
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 
- Since
- Moodle 2.0 
◆ __construct()
      
        
          | custom_menu::__construct | ( |  | $definition = '', | 
        
          |  |  |  | $currentlanguage = null ) | 
      
 
Creates the custom menu. 
- Parameters
- 
  
    | string | $definition | the menu items definition in syntax required by convert_text_to_menu_nodes() |  | string | $currentlanguage | the current language code, null disables multilang support |  
 
 
 
◆ add()
  
  | 
        
          | custom_menu_item::add | ( |  | $text, |  
          |  |  | moodle_url | $url = null, |  
          |  |  |  | $title = null, |  
          |  |  |  | $sort = null, |  
          |  |  |  | $attributes = [] ) |  | inherited | 
 
Adds a custom menu item as a child of this node given its properties. 
- Parameters
- 
  
    | string | $text |  |  | moodle_url | $url |  |  | string | $title |  |  | int | $sort |  |  | array | $attributes | Array of other HTML attributes for the custom menu item. |  
 
- Return values
- 
  
  
 
 
◆ convert_text_to_menu_nodes()
  
  | 
        
          | static custom_menu::convert_text_to_menu_nodes | ( |  | $text, |  
          |  |  |  | $language = null ) |  | static | 
 
Converts a string into a structured array of custom_menu_items which can then be added to a custom menu. 
Structure: text|url|title|langs The number of hyphens at the start determines the depth of the item. The languages are optional, comma separated list of languages the line is for.
Example structure: First level first item|http://www.moodle.com/ -Second level first item|http://www.moodle.com/partners/ -Second level second item|http://www.moodle.com/hq/ –Third level first item|http://www.moodle.com/jobs/ -Second level third item|http://www.moodle.com/development/ First level second item|http://www.moodle.com/feedback/ First level third item English only|http://moodle.com|English only item|en German only|http://moodle.de|Deutsch|de,de_du,de_kids
- Parameters
- 
  
    | string | $text | the menu items definition |  | string | $language | the language code, null disables multilang support |  
 
- Return values
- 
  
  
 
 
◆ export_for_template()
Export this data so it can be used as the context for a mustache template. 
- Parameters
- 
  
    | renderer_base | $output | Used to do a final render of any components that need to be rendered for export. |  
 
- Return values
- 
  
  
Implements templatable.
 
 
◆ get_children()
  
  | 
        
          | custom_menu_item::get_children | ( |  | ) |  |  | inherited | 
 
Sorts and returns the children for this item. 
- Return values
- 
  
  
 
 
◆ get_parent()
  
  | 
        
          | custom_menu_item::get_parent | ( |  | ) |  |  | inherited | 
 
Gets the parent this child belong to. 
- Return values
- 
  
  
 
 
◆ get_sort_order()
  
  | 
        
          | custom_menu_item::get_sort_order | ( |  | ) |  |  | inherited | 
 
Gets the sort order for this child. 
- Return values
- 
  
  
 
 
◆ get_text()
  
  | 
        
          | custom_menu_item::get_text | ( |  | ) |  |  | inherited | 
 
Returns the text for this item. 
- Return values
- 
  
  
 
 
◆ get_title()
  
  | 
        
          | custom_menu_item::get_title | ( |  | ) |  |  | inherited | 
 
Returns the title for this item. 
- Return values
- 
  
  
 
 
◆ get_url()
  
  | 
        
          | custom_menu_item::get_url | ( |  | ) |  |  | inherited | 
 
Returns the url for this item. 
- Return values
- 
  
  
 
 
◆ has_children()
  
  | 
        
          | custom_menu_item::has_children | ( |  | ) |  |  | inherited | 
 
Returns true if this item has any children. 
- Return values
- 
  
  
 
 
◆ override_children()
      
        
          | custom_menu::override_children | ( | array | $children | ) |  | 
      
 
Overrides the children of this custom menu. 
Useful when getting children from $CFG->custommenuitems
- Parameters
- 
  
  
 
 
◆ remove_child()
Removes a custom menu item that is a child or descendant to the current menu. 
Returns true if child was found and removed.
- Parameters
- 
  
  
- Return values
- 
  
  
 
 
◆ set_text()
  
  | 
        
          | custom_menu_item::set_text | ( |  | $text | ) |  |  | inherited | 
 
Sets the text for the node. 
- Parameters
- 
  
  
 
 
◆ set_title()
  
  | 
        
          | custom_menu_item::set_title | ( |  | $title | ) |  |  | inherited | 
 
Sets the title for the node. 
- Parameters
- 
  
  
 
 
◆ set_url()
Sets the url for the node. 
- Parameters
- 
  
  
 
 
◆ sort_custom_menu_items()
Sorts two custom menu items. 
This function is designed to be used with the usort method usort($this->children, array('custom_menu','sort_custom_menu_items'));
- Parameters
- 
  
  
- Return values
- 
  
  
 
 
◆ $title
  
  | 
        
          | string custom_menu_item::$title |  | protectedinherited | 
 
A title to apply to the item. 
By default the text 
 
 
The documentation for this class was generated from the following file: