Actions

API15

JHTMLList/category

From Joomla! Documentation

< API15:JHTMLList
Revision as of 12:30, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
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

[<! removed edit link to red link >]

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

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;
}

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

Examples

<CodeExamplesForm />