API15

Difference between revisions of "JMenu/getItems"

From Joomla! Documentation

< API15:JMenu
(New page: ===Description=== Gets menu items by attribute <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </...)
 
m (removing red link to edit, no existant pages)
(One intermediate revision by one other user not shown)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JMenu/getItems|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JMenu/getItems}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 27: Line 27:
 
| $firstonly
 
| $firstonly
 
| false
 
| false
|  If true, only returns the first item found
+
|  If true, only returns the first item found  
 
|}
 
|}
  
Line 40: Line 40:
 
===Source Body===
 
===Source Body===
 
<source lang="php">
 
<source lang="php">
public function getItems($attribute, $value, $firstonly = false)
+
function getItems($attribute, $value, $firstonly = false)
 
{
 
{
 
         $items = null;
 
         $items = null;
  
         foreach ($this->_items as $item) {
+
         foreach ($this->_items as $item)
                 if (!is_object($item)) {
+
        {
 +
                 if ( ! is_object($item) )
 
                         continue;
 
                         continue;
                }
 
  
                 if ($item->$attribute == $value) {
+
                 if ($item->$attribute == $value)
                         if ($firstonly) {
+
                {
 +
                         if($firstonly) {
 
                                 return $item;
 
                                 return $item;
 
                         }
 
                         }
  
                         $items[] = &$item;
+
                         $items[] = $item;
 
                 }
 
                 }
 
         }
 
         }
Line 63: Line 64:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JMenu/getItems|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JMenu/getItems}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 78: Line 79:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 13:36, 12 May 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Gets menu items by attribute

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

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[edit]

array

Defined in[edit]

libraries/joomla/application/menu.php

Importing[edit]

jimport( 'joomla.application.menu' );

Source Body[edit]

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />