API16

Difference between revisions of "JHtmlMenu/menuitems"

From Joomla! Documentation

< API16:JHtmlMenu
(New page: ===Description=== Returns an array of menu items groups by menu. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JHtmlMenu/menuitems|Edit Descripton]...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JHtmlMenu/menuitems|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JHtmlMenu/menuitems}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 89: Line 89:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JHtmlMenu/menuitems|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JHtmlMenu/menuitems}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 104: Line 104:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Revision as of 21:58, 13 May 2013

The "API16" 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]

Returns an array of menu items groups by menu.

[<! removed edit link to red link >]

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

Syntax[edit]

static menuitems($config=array())
Parameter Name Default Value Description
$config array() An array of configuration options.

Returns[edit]

array

Defined in[edit]

libraries/joomla/html/html/menu.php

Importing[edit]

jimport( 'joomla.html.html.menu' );

Source Body[edit]

public static function menuitems($config = array())
{
        if (empty(self::$items))
        {
                $db = JFactory::getDbo();
                $db->setQuery(
                        'SELECT menutype As value, title As text' .
                        ' FROM #__menu_types' .
                        ' ORDER BY title'
                );
                $menus = $db->loadObjectList();

                $query  = $db->getQuery(true);
                $query->select('a.id AS value, a.title As text, a.level, a.menutype');
                $query->from('#__menu AS a');
                $query->where('a.parent_id > 0');
                $query->where('a.type <> '.$db->quote('url'));

                // Filter on the published state
                if (isset($config['published'])) {
                        $query->where('a.published = '.(int) $config['published']);
                }

                $query->order('a.lft');

                $db->setQuery($query);
                $items = $db->loadObjectList();

                // Collate menu items based on menutype
                $lookup = array();
                foreach ($items as &$item) {
                        if (!isset($lookup[$item->menutype])) {
                                $lookup[$item->menutype] = array();
                        }
                        $lookup[$item->menutype][] = &$item;

                        $item->text = str_repeat('- ',$item->level).$item->text;
                }
                self::$items = array();

                foreach ($menus as &$menu) {
                        self::$items[] = JHtml::_('select.optgroup',    $menu->text);
                        self::$items[] = JHtml::_('select.option', $menu->value.'.0', JText::_('COM_MENUS_ADD_TO_THIS_MENU'));

                        if (isset($lookup[$menu->value])) {
                                foreach ($lookup[$menu->value] as &$item) {
                                        self::$items[] = JHtml::_('select.option', $menu->value.'.'.$item->value, $item->text);
                                }
                        }
                }
        }

        return self::$items;
}

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

Examples[edit]

<CodeExamplesForm />