Back to ListHelper class

Method ordering

public static string
ordering
(mixed $name, mixed $query, mixed $attribs = null, mixed $selected = null, mixed $neworder = null, ?string $id = null)
Build the select list for Ordering derived from a query
Parameters
  • int $name The scalar value
  • string $query The query
  • string $attribs HTML tag attributes
  • string $selected The selected item
  • int $neworder 1 if new and first, -1 if new and last, 0 or null if existing item
  • string $id ID attribute for the resulting <select> element
Returns
  • string HTML markup for the select list
Since
  • 1.6
Class: ListHelper
Project: Joomla

Method ordering - Source code

/**
 * Build the select list for Ordering derived from a query
 *
 * @param   integer  $name      The scalar value
 * @param   string   $query     The query
 * @param   string   $attribs   HTML tag attributes
 * @param   string   $selected  The selected item
 * @param   integer  $neworder  1 if new and first, -1 if new and last, 0  or null if existing item
 * @param   string   $id        ID attribute for the resulting <select> element
 *
 * @return  string   HTML markup for the select list
 *
 * @since   1.6
 */
public static function ordering($name, $query, $attribs = null, $selected = null, $neworder = null, ?string $id = null)
{
    if (empty($attribs)) {
        $attribs = 'size="1"';
    }
    if (empty($neworder)) {
        $orders = HTMLHelper::_('list.genericordering', $query);
        $html = HTMLHelper::_('select.genericlist', $orders, $name, ['list.attr' => $attribs, 'list.select' => (int) $selected, 'id' => $id ?? false]);
    } else {
        if ($neworder > 0) {
            $text = Text::_('JGLOBAL_NEWITEMSLAST_DESC');
        } elseif ($neworder <= 0) {
            $text = Text::_('JGLOBAL_NEWITEMSFIRST_DESC');
        }
        $html = '<input type="hidden" name="' . $name . '" value="' . (int) $selected . '"><span class="readonly">' . $text . '</span>';
    }
    return $html;
}
OSZAR »