JHtmlAccess/level: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Displays a list of the available access view levels
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JHtmlAccess/level|Edit Descript... |
m preparing for archive only |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
Displays a list of the available access view levels | Displays a list of the available access view levels | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 88: | Line 86: | ||
</source> | </source> | ||
<! removed transcluded page call, red link never existed > | |||
< | |||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=level | category=level | ||
category=JHtmlAccess | category=JHtmlAccess | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API16]] | |||
Latest revision as of 01:44, 25 March 2017
Description
Displays a list of the available access view levels
<! 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 transcluded page call, red link never existed >
Examples
Code Examples