JHTMLList/genericordering
From Joomla! Documentation
< API15:JHTMLListRevision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Description
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
...)
Revision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Description
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
...)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API15" 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]
Description
Template:Description:JHTMLList/genericordering
Syntax[edit]
genericordering($sql, $chop= '30')
Parameter Name | Default Value | Description |
---|---|---|
$sql | SQL with ordering As value and 'name field' AS text | |
$chop | '30' | The length of the truncated headline |
Defined in[edit]
libraries/joomla/html/html/list.php
Importing[edit]
jimport( 'joomla.html.html.list' );
Source Body[edit]
function genericordering( $sql, $chop = '30' )
{
$db =& JFactory::getDBO();
$order = array();
$db->setQuery( $sql );
if (!($orders = $db->loadObjectList())) {
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
} else {
$order[] = JHTML::_('select.option', 1, JText::_( 'first' ) );
return $order;
}
}
$order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) );
for ($i=0, $n=count( $orders ); $i < $n; $i++) {
if (JString::strlen($orders[$i]->text) > $chop) {
$text = JString::substr($orders[$i]->text,0,$chop)."...";
} else {
$text = $orders[$i]->text;
}
$order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' );
}
$order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) );
return $order;
}
[Edit See Also] Template:SeeAlso:JHTMLList/genericordering
Examples[edit]
<CodeExamplesForm />