php - Change "Click to sort by this column" default text using jHtml::_('grid.sort' -
i'm writing backend component, columns generated this:
<th><?php echo jhtml::_('grid.sort', 'column title', 'table_column', $listdirn, $listorder) ?></th>
in backend, when hold mouse on column header, message: "click sort column."
we want use tool tips , title tag give deeper explanations on each column instead of default message. came across page: https://docs.joomla.org/api17:jhtmljgrid::action
public static function action ( $i $task $prefix='' $text='' $active_title='' $inactive_title='' $tip=false $active_class='' $inactive_class='' $enabled=true $translate=true $checkbox='cb' )
but have been unsuccessful in getting tooltip fire. ideas on overriding default message?
ok investigated little bit , seems jhtml::_('grid.sort', 'column title', 'table_column', $listdirn, $listorder)
triggering jhtmlgrid::sort
in libraries/cms/html/grid.php
.
this class in particular allow "improve" text in tooltip.
said "improve" because text "click sort column." hardcoded , custom text above text.
to have use following code:
jhtml::_('grid.sort', 'column title', 'table_column', $listdirn, $listorder, null, 'asc', '<h1>here custom code</h1> wow <b>html</b>!');
ok want remove "click sort column." , how can ?
create new file in component called mysort.php eg. in there require libraries/cms/html/grid.php
, create new class mysort extend jhtmlgrid.
in there copy method sort jhtmlgrid
, remove constant jglobal_click_to_sort_this_column
.
ok able use mysort::sort('column title', 'table_column', $listdirn, $listorder, null, 'asc', '<h1>here custom code</h1> wow <b>html</b>!')
;
class mygrid extends jhtmlgrid { public static function sort($title, $order, $direction = 'asc', $selected = '', $task = null, $new_direction = 'asc', $tip = '') { jhtml::_('behavior.core'); jhtml::_('bootstrap.tooltip'); $direction = strtolower($direction); $icon = array('arrow-up-3', 'arrow-down-3'); $index = (int) ($direction == 'desc'); if ($order != $selected) { $direction = $new_direction; } else { $direction = ($direction == 'desc') ? 'asc' : 'desc'; } $html = '<a href="#" onclick="joomla.tableordering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\');return false;"' . ' class="hastooltip" title="' . jhtml::tooltiptext(($tip ? $tip : $title)) . '">'; if (isset($title['0']) && $title['0'] == '<') { $html .= $title; } else { $html .= jtext::_($title); } if ($order == $selected) { $html .= ' <i class="icon-' . $icon[$index] . '"></i>'; } $html .= '</a>'; return $html; } }