JMenu/getItems: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 61: | Line 61: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=getItems | category=getItems | ||
category=JMenu | category=JMenu | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 01:54, 25 March 2017
Description
Gets menu items by attribute
Syntax
getItems($attribute, $value, $firstonly=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $attribute | The field name | |
| $value | The value of the field | |
| $firstonly | false | If true, only returns the first item found |
Returns
array
Defined in
libraries/joomla/application/menu.php
Importing
jimport( 'joomla.application.menu' );
Source Body
public function getItems($attribute, $value, $firstonly = false)
{
$items = null;
foreach ($this->_items as $item) {
if (!is_object($item)) {
continue;
}
if ($item->$attribute == $value) {
if ($firstonly) {
return $item;
}
$items[] = $item;
}
}
return $items;
}
Examples
Code Examples