简体   繁体   English

定制分页课程Joomla Virtuemart 2

[英]Custom pagination classes Joomla Virtuemart 2

I need to assign an custom class, lets named it "custom" to the Virtuemart Pagination "Next" link or li. 我需要分配一个自定义类,将其命名为“自定义”到Virtuemart分页“下一个”链接或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? 现在,我的Ul中的每个Li都有“下一个”类,但是我应该使用什么代码来使Li(带有指向下一页的链接)具有自定义类?

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

I have found the answer here http://forum.joomla.org/viewtopic.php?t=444384 . 我在这里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. 我用它来安装无限的ajax滚动脚本,它可以完美地工作。

You can set the custom class CSS using: 您可以使用以下方法设置自定义类CSS:

li.next {

}

See MDN about CSS . 请参阅有关CSS的MDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM