dede模板标签arclist实现分页
操作方法
- 01
思路:{dede:arclist typeid='2,3' row='10000'}将所有要调用的文章调用出来(row =10000),在前端使用JS实现分页步骤:
- 02
在头部引入JS文件和分页样式文件,这里使用的是jPaginate Jquery分页<link href="{dede:global.cfg_templets_skin/}/style/jPaginate.css" rel="stylesheet" media="screen" type="text/css" /><script language="javascript" type="text/javascript" src="{dede:global.cfg_templets_skin/}/js/jquery.js"></script>
- 03
根据jPaginate的示例文件来调整下模板代码<div id="paginationdemo"> {dede:arclist typeid='2,3' row='10000'} [field:global.autoindex runphp="yes"] if (@me==1)@me="<div id='p1' class='pagedemo _current'>"; elseif ((@me-1)%10==0) @me="<div id='p".(floor(@me/10)+1)."' class='pagedemo' style='display:none'>";else @me="";[/field:global.autoindex] <li>Page[field:global.autoindex/] [field:title/] </li> [field:global.autoindex runphp="yes"] $a="select count(*) as b from dede_archives where typeid in(2,3) and arcrank>-1"; $arcRow = $GLOBALS['db']->GetOne($a); $tt=$arcRow['b']; $me=intval(@me); $tt=intval($tt);//echo $me;echo $tt; if (@me==10)@me="</div>"; elseif(@me!=1&&((@me)%10==0)&&$me!=$tt) @me="</div>";elseif($me==$tt) @me="</div>"; else @me="";[/field:global.autoindex] {/dede:arclist} <div id="demo5"> </div> </div>
- 04
在2的的下面引入jPaginate 参数<script src="{dede:global.cfg_templets_skin/}/js/jquery.paginate.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $("#demo5").paginate({ count : {dede:arclist typeid='1' row='10000'} [field:global.autoindex runphp="yes"] $b="select count(*) as c from dede_archives where typeid in(2,3) and arcrank>-1"; $arcRow2 = $GLOBALS['db']->GetOne($b); $tt2=$arcRow2['c']; $me2=intval(@me); $tt2=intval($tt2); //var_dump($tt2);var_dump($me2); if($me2==$tt2){ @me=floor($tt2/10)+1; }else{ @me=''; } [/field:global.autoindex] {/dede:arclist} , start : 1, display : 3, border : true, border_color : '#fff', text_color : '#000', background_color : '#FBFAFA', border_hover_color : '#ccc', text_hover_color : '#f00', background_hover_color : '#2D2D2D', images : false, mouse : 'press', onChange : function(page){ $('._current','#paginationdemo').removeClass('_current').hide(); $('#p'+page).addClass('_current').show(); } }); }); </script>备注:1.完整文件请参考附件, 1 2 3代码都在list_article_fenye.htm中2.dedecms5.7版本已经测试通过3.感谢xiaoq的支持4.如果有问题,请及时沟通,共同改进