Menuitem form field type

From Joomla! Documentation

Revision as of 07:03, 31 July 2019 by FuzzyBot (talk | contribs) (Updating to match new version of source page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
English • ‎Nederlands • ‎español • ‎français

The menuitem form field type provides a drop down grouped list of the available menu items from your Joomla site.

Params.menuitem.jpg
  • type (mandatory) must be menuitem.
  • name (mandatory) is the unique name of the field.
  • label (mandatory) (translatable) is the descriptive title of the field.
  • default (optional) is the default menu item. Note that this is the ItemID number of the menu item.
  • description (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.
  • published (optional) determines whether all menu items are listed or only published menu items. If state is '0' then all menu items will be listed. If state is '1' then only published menu items will be listed. You also can use comma separated values like '1,2'.
  • menu_type (optional) filters by the menutype value in database table #__menu or rather the value of form field Menu Type in edit form of a menu.
  • client_id (optional) filters by the client_id value in database table #__menu. '0' for site menu items. '1' for administrator menu items. The default value is '0'.
  • language (optional) filters by the language value in database table #__menu (language tags). You can also use comma separated values like 'en-GB,de-DE'.

To add additional rows with translatable strings (such as "Select" or "Default") add an option to the XML. For example:

<option	value="">JDEFAULT</option>

Example XML field definition:

<field name="mymenuitem" type="menuitem" default="45" label="Select a menu item" description="Select a menu item" />

Resolving a URL

The menuitem form field type gives the ID of the selected menu item. To get a search engine friendly URL using the ID, use JRoute:

JRoute::_("index.php?Itemid={$id}");

See also