Documentation Menu

1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 11 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Manual arrow 11. API Reference arrow mosHTML::sortIcon

mosHTML::sortIcon PDF Print E-mail

Last reviewed: Not reviewed
phpDocumentor

mosHTML::sortIcon

Builds the HTML code for displaying a standard clickable sort icon.  The alternative text for the image is taken from the current language settings.

Syntax

string sortIcon ( string $base_href, string $field [, string $state] )

$base_href
is the base URL that will be used if the user clicks the image.
$field
is the name of the field that is being sorted.
$state
is the current sort state of the field.  This parameter is optional and if omitted will default to 'none'.  Possible values are:
none
indicates that the field is not currently sorted.  Clicking the image will request an ascending sort.
asc
indicates that the field is currently sorted in ascending order.  Clicking the image will request a descending sort.
desc
indicates that the field is currently sorted in descending order.  Clicking the image will request an ascending sort.

Examples

Example: This example (abstracted from the com_statistics component) shows the construction of an array, $sorts, containing the HTML for two sort icons.

// get sort field and check against allowable field names
$field = strtolower( mosGetParam( $_REQUEST, 'field', '' ) );
if (!in_array( $field, array( 'agent', 'hits' ) )) {
  $field = '';
}
 
// get field ordering or set the default field to order
$order = strtolower( mosGetParam( $_REQUEST, 'order', 'asc' ) );
if ($order != 'asc' && $order != 'desc' && $order != 'none') {
  $order = 'asc';
} else if ($order == 'none') {
  $field = 'agent';
  $order = 'asc';
}
 
// browser stats
$order_by = '';
$sorts = array();
$sort_base = "index2.php?option=$option&task=$task";
 
switch ($field) {
  case 'hits':
    $order_by = "hits $order";
    $sorts['agent'] = mosHTML::sortIcon( "$sort_base", "agent" );
    $sorts['hits']  = mosHTML::sortIcon( "$sort_base", "hits", $order );
    break;
 
  case 'agent':
  default:
    $order_by = "agent $order";
    $sorts['agent'] = mosHTML::sortIcon( "$sort_base", "agent", $order );
    $sorts['hits']  = mosHTML::sortIcon( "$sort_base", "hits" );
    break;
}
 
$database->setQuery( "SELECT * FROM #__stats_agents WHERE type='0' ORDER BY $order_by" );
$browsers = $database->loadObjectList();

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Wednesday, 28 September 2005 )
 
< Prev   Next >