akcms实现栏目分页静态生成
首先明确下栏目的设置:
akcms的栏目设置中有别名和栏目两个字段,别名是用来做SEO的,给栏目取别的名称,栏目是用来定义URL的,我一般用栏目名称的英文或者全拼。
然后在栏目模板里使用以下分页代码:
<{getpaging page=$page
paging="[first][previous][paging][next][last]"
firstpage="$path/"
baseurl="$path/[page].html"
template="<a href='[url]'>[page]</a>"
currenttemplate="<span>[page]</span>"
previoustemplate="<a href='[url]'>上一页</a>"
noprevioustemplate="<span>上一页</span>"
nexttemplate="<a href='[url]'>上一页</a>"
nonexttemplate="<span>上一页</span>"
firsttemplate="<a href='[url]'>第一页</a>"
alreadyfirsttemplate="<span>第一页</span>"
lasttemplate="<a href='[url]'>最后一页</a>"
alreadylasttemplate="<span>最后一页</span>"
}>
要让该分页代码生效,栏目模板里的getitems标签必须添加page=$page bandindex="1"参数。
getpaging标签特别说明:
1,baseurl="$path/[page].html"用来生成栏目分页的,特别是$path不要写成$alias或者[path]、<{$path}>之类的。
2,为了seo,一般要使用firstpage="$path/"
3,paging="firstpaging[last]"并不是有了这个参数都行,一定要把对应参数定义了,前台解析时才会显示对应的第一页分页[最后一页]
[first]......对应firsttemplate和alreadyfirsttemplate参数
[previous]......对应previoustemplate和noprevioustemplate参数
[paging]......对应template参数
[next]......对应nexttemplate和nonexttemplate参数
[last]......对应lasttemplate和alreadylasttemplate参数
更详细的用法参考:http://www.akhtm.com/manual/getpaging.htm
2018.04.15更新:
一,上面分页代码中,如果网站栏目存在二级三级,其中的$path要写成$fullpath,不然不会正常生成。
二,在akcms老版本中,比如akcms4.3,分页代码可参考代码:
<{getpaging page=$page template="<a href='../$path/index_[page].html'>[page]</a>" currenttemplate="[page]" firstpagetemplate="<a href='../$path/'>1</a>" linktemplate="[link] "}>
原文链接: akcms实现栏目分页静态生成