а вот код плагина <?php
/**
* @package jlvklike
* @author Anton Voynov (anton@joomline.net)
* @version 1.2
* @copyright (C) 2010 by Anton Voynov(
http://www.joomline.net)
* @license JoomLine:
http://joomline.net/licenzija-joomline.html *
*/
defined('JPATH_BASE') or die();
/**
* Renders a multiple item select element
* using SQL result and explicitly specified params
*
*/
class JElementMulticatlist extends JElement
{
/**
* Element name
*
* @access protected
* @var string
*/
var $_name = 'multicatlist';
function fetchElement($name, $value, &$node, $control_name)
{
// Base name of the HTML control.
$ctrl = $control_name .'['. $name .']';
// Construct the various argument calls that are supported.
$attribs = ' ';
if ($v = $node->attributes( 'size' )) {
$attribs .= 'size="'.$v.'"';
}
if ($v = $node->attributes( 'class' )) {
$attribs .= 'class="'.$v.'"';
} else {
$attribs .= 'class="inputbox"';
}
if ($m = $node->attributes( 'multiple' ))
{
$attribs .= ' multiple="multiple"';
$ctrl .= '[]';
}
// Query items for list.
$db = & JFactory::getDBO();
$key = 'id';
$val = 'catname';
$db->setQuery(" SELECT c.id, c.title as catname, s.title as section
FROM #__categories c
LEFT JOIN #__sections s ON c.section = s.id
WHERE c.published = 1 AND s.published=1
ORDER BY section, catname");
$rows = $db->loadAssocList();
if (count($node->children())>0)
foreach ($node->children() as $option) {
$options[]= array($key=> $option->attributes('value'),$val => $option->data());
}
$lastgrp = '';
if (count($rows)>0)
foreach ($rows as $row){
if ($row['section'] != $lastgrp) {
$options[] = array($key=>"<OPTGROUP>",$val=>$row['section']);
$lastgrp = $row['section'];
}
$options[]=array($key=>$row[$key],$val=>$row[$val]);
}
if($options){
return JHTML::_('select.genericlist',$options, $ctrl, $attribs, $key, $val, $value, $control_name.$name);
}
}
}