其实是增加一个判别语句。
以资讯为例:
打开templates/default/news_index.html.php
找到
- <!--{loop $_SBLOCK[category] $key $cat}-->
- <div class="miniblock">
- <a href="#action/category/catid/$cat[catid]#" class="more">MORE</a>
- <h3>$cat[name]</h3>
- <ul>
- <!--{eval $cachetime=1800+25*$key;}-->
- <!--{block name="spacenews" parameter="catid/$cat[catid]/order/i.dateline
- DESC/limit/0,10/cachetime/$cachetime/subjectlen/40/tpl/item_subject_list"}--><!--最新列表-->
- </ul>
- </div>
- <!--{/loop}-->
复制代码
替换为
- <!--{loop $_SBLOCK[category] $key $cat}-->
- <div class="miniblock">
- <a href="#action/category/catid/$cat[catid]#" class="more">MORE</a>
- <h3>$cat[name]</h3>
- <ul>
- <!--{if ($cat[catid]==2)}-->
- <!--{block name="spacenews" parameter="catid/2,11,12,13/order/i.dateline
- DESC/limit/0,10/cachetime/55555/subjectlen/40/tpl/item_subject_list"}--><!--最新列表-->
- <!--{/if}-->
- <!--{eval $cachetime=1800+25*$key;}-->
- <!--{block name="spacenews" parameter="catid/$cat[catid]/order/i.dateline
- DESC/limit/0,10/cachetime/$cachetime/subjectlen/40/tpl/item_subject_list"}--><!--最新列表-->
- </ul>
- </div>
- <!--{/loop}-->
复制代码
其实就增加了以下判别语句:
<!--{if ($cat[catid]==2)}-->
<!--{block name="spacenews" parameter="catid/2,11,12,13/order/i.dateline
DESC/limit/0,10/cachetime/55555/subjectlen/40/tpl/item_subject_list"}--><!--最新列表-->
<!--{/if}-->
其中,$cat[catid]==2中的数字2,是含有子分类的根分类的id
科技资讯列出的是根分类的名称
catid/2,11,12,13列出的是该根分类下需要显示的分类内容的id,包括根分类(子分类ID是11,12,13根分类是2)
cachetime/55555代表缓存时间,以s计算
limit/0,10代表列出的条目数
这个是列出一个分类,如果需要列几个分类,只需要将上面的判别代码重复几遍并修改其中对应参数即可。
对于分类的id,可以到站点设置--资讯分类--将鼠标放在编辑上--可以在地址栏看到其catid编号 |