Actions

API15

JHTMLList/genericordering

From Joomla! Documentation

< API15:JHTMLList
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Description

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

libraries/joomla/html/html/list.php

Importing

jimport( 'joomla.html.html.list' );

Source Body

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />