Actions

API15

JElementCategory/fetchElement

From Joomla! Documentation

< API15:JElementCategory
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.

[<! removed edit link to red link >]

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

Contents

Syntax

fetchElement($name, $value, &$node, $control_name)
Parameter Name Default Value Description
$name
$value
&$node
$control_name

Defined in

libraries/joomla/html/parameter/element/category.php

Importing

jimport( 'joomla.html.parameter.element.category' );

Source Body

function fetchElement($name, $value, &$node, $control_name)
{
        $db = &JFactory::getDBO();
 
        $section        = $node->attributes('section');
        $class          = $node->attributes('class');
        if (!$class) {
                $class = "inputbox";
        }
 
        if (!isset ($section)) {
                // alias for section
                $section = $node->attributes('scope');
                if (!isset ($section)) {
                        $section = 'content';
                }
        }
 
        if ($section == 'content') {
                // This might get a conflict with the dynamic translation - TODO: search for better solution
                $query = 'SELECT c.id, CONCAT_WS( "/",s.title, c.title ) AS title' .
                        ' FROM #__categories AS c' .
                        ' LEFT JOIN #__sections AS s ON s.id=c.section' .
                        ' WHERE c.published = 1' .
                        ' AND s.scope = '.$db->Quote($section).
                        ' ORDER BY s.title, c.title';
        } else {
                $query = 'SELECT c.id, c.title' .
                        ' FROM #__categories AS c' .
                        ' WHERE c.published = 1' .
                        ' AND c.section = '.$db->Quote($section).
                        ' ORDER BY c.title';
        }
        $db->setQuery($query);
        $options = $db->loadObjectList();
        array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Category').' -', 'id', 'title'));
 
        return JHTML::_('select.genericlist',  $options, ''.$control_name.'['.$name.']', 'class="'.$class.'"', 'id', 'title', $value, $control_name.$name );
}

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

Examples

<CodeExamplesForm />