From Joomla! Documentation

< API16:JHtmlAccess

The "API16" 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.


Displays a list of the available access view levels

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


static level($name, $selected, $attribs= '', $params=true, $id=false)
Parameter Name Default Value Description
$name The form field name.
$selected The name of the selected section.
$attribs Additional attributes to add to the select field.
$params true True to add "All Sections" option or and array of option
$id false The form field id


string The required HTML for the SELECT tag.

Defined in



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

Source Body

public static function level($name, $selected, $attribs = '', $params = true, $id = false)
        $db             = JFactory::getDbo();
        $query  = $db->getQuery(true);

        $query->select('a.id AS value, a.title AS text');
        $query->from('#__viewlevels AS a');
        $query->order('a.ordering ASC');
        $query->order('`title` ASC');

        // Get the options.
        $options = $db->loadObjectList();

        // Check for a database error.
        if ($db->getErrorNum()) {
                JError::raiseWarning(500, $db->getErrorMsg());
                return null;

        // If params is an array, push these options to the array
        if (is_array($params)) {
                $options = array_merge($params,$options);
        // If all levels is allowed, push it into the array.
        elseif ($params) {
                array_unshift($options, JHtml::_('select.option', '', JText::_('JOption_Access_Show_All_Levels')));

        return JHtml::_('select.genericlist', $options, $name,
                        'list.attr' => $attribs,
                        'list.select' => $selected,
                        'id' => $id

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


Code Examples