API15

JHTMLList/category

From Joomla! Documentation

< API15:JHTMLList
Revision as of 19:52, 24 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

[<! removed edit link to red link >]

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

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

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

Examples[edit]

Code Examples[edit]