API15

JHTMLList/category

From Joomla! Documentation

< API15:JHTMLList
Revision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Select list of active categories for components <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JHTMLList/category|Edit Descripton...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Select list of active categories for components

[Edit Descripton]

Template:Description:JHTMLList/category

Syntax[edit]

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[edit]

libraries/joomla/html/html/list.php

Importing[edit]

jimport( 'joomla.html.html.list' );

Source Body[edit]

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] Template:SeeAlso:JHTMLList/category

Examples[edit]

<CodeExamplesForm />