API15

JElementCategory/fetchElement

From Joomla! Documentation

< API15:JElementCategory
Revision as of 17:16, 22 March 2010 by Doxiki (talk | contribs) (New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JElementCa...)
(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.

[Edit Descripton]

Template:Description:JElementCategory/fetchElement

Syntax[edit]

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

Defined in[edit]

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

Importing[edit]

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

Source Body[edit]

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

[Edit See Also] Template:SeeAlso:JElementCategory/fetchElement

Examples[edit]

<CodeExamplesForm />