Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Created June 12, 2013 17:30
Show Gist options
  • Save betweenbrain/5767388 to your computer and use it in GitHub Desktop.
Save betweenbrain/5767388 to your computer and use it in GitHub Desktop.
Joomla 1.5 multiple select menu item custom parameter type
<?php defined('_JEXEC') or die;
/**
* File menuitems.php
* Created 6/12/13 11:37 AM
* Author Matt Thomas | matt@betweenbrain.com | http://betweenbrain.com
* Support https://github.com/betweenbrain/
* Copyright Copyright (C) 2013 betweenbrain llc. All Rights Reserved.
* License GNU GPL v3 or later
*/
class JElementMenuitems extends JElement {
var $name = 'Menuitems';
function fetchElement($name, $value, &$node, $control_name) {
// Strip out administrator directory of returned value for JPATH_BASE
$site = str_replace('/administrator', '', JPATH_BASE);
// Manually register JHTMLMenu class
JLoader::register('JHTMLMenu', $site . '/libraries/joomla/html/html/menu.php', TRUE);
// Retrieve all site menu items as an array
$items = JHTMLMenu::linkoptions();
/*
* Build the multi select list
*
* $control_name . '[' . $name . '][]' allows us to pass an array into the params object
*
* - $control_name = params
* - $name is passed from the xml document
*/
$attribs = 'multiple="true" size="12"';
return JHTML::_('select.genericlist', $items, $control_name . '[' . $name . '][]', $attribs, 'value', 'text', $value, $control_name . $name);
}
}
/*
* References
*
* - http://docs.joomla.org/API15:JHTMLSelect/genericlist
* - http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=15420 (see element.zip)
* - http://forum.joomla.org/viewtopic.php?p=1439223
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment