Question

I need to assign an custom class, lets named it "custom" to the Virtuemart Pagination "Next" link or li. Now every Li from my Ul had class "Next", but what code i should use to make Li with the link to the next page had custom class?

Here is the code

function pagination_item_active(&$item) {

    $cls = '';

    if ($item->text == JText::_('Next')) { $item->text = '»'; $cls = "next";}
    if ($item->text == JText::_('Prev')) { $item->text = '«'; $cls = "previous";}

    if ($item->text == JText::_('First')) { $cls = "first";}
    if ($item->text == JText::_('Last'))   { $cls = "last";}

    return "<li class=\"next\"><a class=\"".$cls."\" href=\"".$item->link."\" title=\"".$item->text."\">".$item->text."</a></li>";
}


function pagination_item_inactive(&$item) {
    return "<li class=\"pagination-active\"><a>".$item->text."</a></li>";
}
Was it helpful?

Solution

I have found the answer here http://forum.joomla.org/viewtopic.php?t=444384. Here is the final solution code:

function pagination_list_render($list)
{
   $lang =& JFactory::getLanguage();
   $html = "<ul class=\"pagination\">";

   $html .= '<li class="first">'.$list['start']['data'].'</li>';
   $html .= '<li class="prev">'.$list['previous']['data'].'</li>';

   foreach( $list['pages'] as $page )
   {
      $html .= '<li class="num">'.$page['data'].'</li>';
   }
   $html .= '<li class="next">'.$list['next']['data'].'</li>';
   $html .= '<li class="end">'.$list['end']['data'].'</li>';

   $html .= "</ul>";
   return $html;
}

function pagination_item_active(&$item) {
   return "<a href=\"".$item->link."\" class=\"active\" title=\"".$item->text."\">".$item->text."</a>";
}

function pagination_item_inactive(&$item) {
   return "<span class=\"inactive\">".$item->text."</span>";
}

I use it to install infinite ajax scroll script, and it works perfectly.

OTHER TIPS

You can set the custom class CSS using:

li.next {

}

See MDN about CSS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top