我们在制作dedecms模板时,源代码中的[field:global name=autoindex/]标签很好用可以调用数字序号,此标签最简单的用法就是按内容条数来获取数字序号,但有的时候发现使用该标签时无效比如频道页。

channelartlist标签下可以使用{dede:global name=’itemindex’/}

dede:channel标签下直接使用[field:global name=autoindex/]

dede:channel标签当前样式currentstyle下时,需要修改文件,channel.lib.php文件,就可以使用~autoindex~ 来调用了

$linkOkstr = $currentstyle; 
$row['typelink'] = GetOneTypeUrlA($row); 
$linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr); 
$linkOkstr = str_replace("~id~",$row['id'],$linkOkstr); 
$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr); 
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr); 

后面加上

$linkOkstr = str_replace("~autoindex~",$GLOBALS['autoindex']+1,$linkOkstr);

 

转载于:https://www.cnblogs.com/jizl/p/4749217.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐