JHtmlAccess/level
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.
Description[edit]
Displays a list of the available access view levels
<! removed transcluded page call, red link never existed >
Syntax[edit]
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[edit]
string The required HTML for the SELECT tag.
Defined in[edit]
libraries/joomla/html/html/access.php
Importing[edit]
jimport( 'joomla.html.html.access' );
Source Body[edit]
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 transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]