API16:JHtmlAccess/level
From Joomla! Documentation
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.
Contents |
Description
Displays a list of the available access view levels
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
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 |
Returns
string The required HTML for the SELECT tag.
Defined in
libraries/joomla/html/html/access.php
Importing
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->group('a.id'); $query->order('a.ordering ASC'); $query->order('`title` ASC'); // Get the options. $db->setQuery($query); $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, array( 'list.attr' => $attribs, 'list.select' => $selected, 'id' => $id ) ); }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
