API15:JHTMLList/category
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Select list of active categories for components
Description:JHTMLList/category
Syntax
category($name, $section, $active=NULL, $javascript=NULL, $order= 'ordering', $size=1, $sel_cat=1)
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | ||
| $section | ||
| $active | NULL | |
| $javascript | NULL | |
| $order | 'ordering' | |
| $size | 1 | |
| $sel_cat | 1 |
Defined in
libraries/joomla/html/html/list.php
Importing
jimport( 'joomla.html.html.list' );
Source Body
function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) { $db =& JFactory::getDBO(); $query = 'SELECT id AS value, title AS text' . ' FROM #__categories' . ' WHERE section = '.$db->Quote($section) . ' AND published = 1' . ' ORDER BY '. $order ; $db->setQuery( $query ); if ( $sel_cat ) { $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); $categories = array_merge( $categories, $db->loadObjectList() ); } else { $categories = $db->loadObjectList(); } $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); return $category; }
[Edit See Also] SeeAlso:JHTMLList/category
Examples
<CodeExamplesForm />
