API16

Difference between revisions of "JHtmlAccess/level"

From Joomla! Documentation

< API16:JHtmlAccess
(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 (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JHtmlAccess/level|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JHtmlAccess/level}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 89: Line 89:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JHtmlAccess/level|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JHtmlAccess/level}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 104: Line 104:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Revision as of 21:56, 13 May 2013

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 edit link to red link >]

<! 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 edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />