JHtmlAccess/section
From Joomla! Documentation
Contents |
Description
Displays a list of the available access sections
Syntax
static JHtmlAccess::section($name, $selected, $attribs= '', $allowAll=true)
| 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. | |
| $allowAll | true | True to add "All Sections" option. |
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 section($name, $selected, $attribs = '', $allowAll = true)
{
$db = &JFactory::getDbo();
$db->setQuery(
'SELECT `id` AS value, `title` AS text'
.' FROM #__access_sections'
.' ORDER BY `ordering`, `title`'
);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseNotice(500, $db->getErrorMsg());
return null;
}
// If all usergroups is allowed, push it into the array.
if ($allowAll) {
array_unshift($options, JHtml::_('select.option', '', JText::_('JOption_Access_Show_All_Sections')));
}
return JHtml::_('select.genericlist', $options, $name,
array(
'list.attr' => $attribs,
'list.select' => $selected
)
);
}