Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • ElggMenuBuilder
  • ElggMenuItem
  • Overview
  • Package
  • Class
  • Tree

Class ElggMenuItem

Elgg Menu Item

To create a menu item that is not a link, pass false for $href.

Package: Elgg\Core\Navigation
Since: 1.8.0
Located at ElggMenuItem.php
Methods summary
public
# __construct( string $name, string $text, string $href )

ElggMenuItem constructor

ElggMenuItem constructor

Parameters

$name
string
$name Identifier of the menu item
$text
string
$text Display text of the menu item
$href
string
$href URL of the menu item (false if not a link)
public static ElggMenuItem
# factory( array $options )

ElggMenuItem factory method

ElggMenuItem factory method

This static method creates an ElggMenuItem from an associative array. Required keys are name, text, and href.

Parameters

$options
array
$options Option array of key value pairs

Returns

ElggMenuItem
or NULL on error
public
# setData( mixed $key, mixed $value = null )

Set a data key/value pair or a set of key/value pairs

Set a data key/value pair or a set of key/value pairs

This method allows storage of arbitrary data with this menu item. The data can be used for sorting, custom rendering, or any other use.

Parameters

$key
mixed
$key String key or an associative array of key/value pairs
$value
mixed
$value The value if $key is a string
public mixed
# getData( string $key )

Get stored data

Get stored data

Parameters

$key
string
$key The key for the requested key/value pair

Returns

mixed
public
# setName( string $name )

Set the identifier of the menu item

Set the identifier of the menu item

Parameters

$name
string
$name Unique identifier
public string
# getName( )

Get the identifier of the menu item

Get the identifier of the menu item

Returns

string
public
# setText( string $text )

Set the display text of the menu item

Set the display text of the menu item

Parameters

$text
string
$text The display text
public string
# getText( )

Get the display text of the menu item

Get the display text of the menu item

Returns

string
public
# setHref( string $href )

Set the URL of the menu item

Set the URL of the menu item

Parameters

$href
string
$href URL or false if not a link
public string
# getHref( )

Get the URL of the menu item

Get the URL of the menu item

Returns

string
public
# setContext( array $contexts )

Set the contexts that this menu item is available for

Set the contexts that this menu item is available for

Parameters

$contexts
array
$contexts An array of context strings
public array
# getContext( )

Get an array of context strings

Get an array of context strings

Returns

array
public boolean
# inContext( string $context = '' )

Should this menu item be used given the current context

Should this menu item be used given the current context

Parameters

$context
string
$context A context string (default is empty string for current context stack).

Returns

boolean
public
# setSelected( boolean $state = true )

Set the selected flag

Set the selected flag

Parameters

$state
boolean
$state Selected state (default is true)
public boolean
# getSelected( )

Get selected state

Get selected state

Returns

boolean
public
# setTooltip( string $text )

Set the tool tip text

Set the tool tip text

Parameters

$text
string
$text The text of the tool tip
public string
# getTooltip( )

Get the tool tip text

Get the tool tip text

Returns

string
public
# setConfirmText( string $text )

Set the confirm text shown when link is clicked

Set the confirm text shown when link is clicked

Parameters

$text
string
$text The text to show
public string
# getConfirmText( )

Get the confirm text

Get the confirm text

Returns

string
public
# setLinkClass( mixed $class )

Set the anchor class

Set the anchor class

Parameters

$class
mixed
$class An array of class names, or a single string class name.
public string
# getLinkClass( )

Get the anchor classes as text

Get the anchor classes as text

Returns

string
public
# addLinkClass( mixed $class )

Add a link class

Add a link class

Parameters

$class
mixed
$class An array of class names, or a single string class name.
public
# setItemClass( mixed $class )

Set the li classes

Set the li classes

Parameters

$class
mixed
$class An array of class names, or a single string class name.
public string
# getItemClass( )

Get the li classes as text

Get the li classes as text

Returns

string
public
# setPriority( integer $priority )

Set the priority of the menu item

Set the priority of the menu item

Parameters

$priority
integer
$priority The smaller numbers mean higher priority (1 before 100)
public integer
# getPriority( )

Get the priority of the menu item

Get the priority of the menu item

Returns

integer
public
# setSection( string $section )

Set the section identifier

Set the section identifier

Parameters

$section
string
$section The identifier of the section
public string
# getSection( )

Get the section identifier

Get the section identifier

Returns

string
public
# setParentName( string $name )

Set the parent identifier

Set the parent identifier

Parameters

$name
string
$name The identifier of the parent ElggMenuItem
public string
# getParentName( )

Get the parent identifier

Get the parent identifier

Returns

string
public
# setParent( ElggMenuItem $parent )

Set the parent menu item

Set the parent menu item

Parameters

$parent
ElggMenuItem
$parent The parent of this menu item
public ElggMenuItem
# getParent( )

Get the parent menu item

Get the parent menu item

Returns

ElggMenuItem
or null
public
# addChild( ElggMenuItem $item )

Add a child menu item

Add a child menu item

Parameters

$item
ElggMenuItem
$item A child menu item
public
# setChildren( array $children )

Set the menu item's children

Set the menu item's children

Parameters

$children
array
$children Array of ElggMenuItems
public array
# getChildren( )

Get the children menu items

Get the children menu items

Returns

array
public
# sortChildren( string $sortFunction )

Sort the children

Sort the children

Parameters

$sortFunction
string
$sortFunction A function that is passed to usort()
public string
# getContent( array $vars = array() )

Get the menu item content (usually a link)

Get the menu item content (usually a link)

Parameters

$vars
array
$vars Options to pass to output/url if a link

Returns

string
Properties summary
protected array $data array( // string Identifier of the menu 'name' => '', // array Page contexts this menu item should appear on 'contexts' => array('all'), // string Menu section identifier 'section' => 'default', // int Smaller priorities float to the top 'priority' => 100, // bool Is this the currently selected menu item 'selected' => false, // string Identifier of this item's parent 'parent_name' => '', // ElggMenuItem The parent object or null 'parent' => null, // array Array of children objects or empty array 'children' => array(), // array Classes to apply to the li tag 'itemClass' => array(), // array Classes to apply to the anchor tag 'linkClass' => array(), )
#

Non-rendered data about the menu item

Non-rendered data about the menu item

protected string $text
#

The menu display string

The menu display string

protected string $href null
#

The menu url

The menu url

protected string $title false
#

Tooltip

Tooltip

protected string $confirm ''
#

The string to display if link is clicked

The string to display if link is clicked

API documentation generated by ApiGen 2.8.0