zdcms循环调用栏目列表的几种情况(包含同时调用主栏目和子栏目的方法)

zdcms循环调用栏目列表的几种方式,包含同时调用主栏目和子栏目的方法。

查询共享栏目的所有顶级栏目

{category module=share pid=0} 
栏目名称{$t.name}
栏目地址{$t.url}
缩略图 {dr_thumb($t.thumb)}
栏目内容{$t.content}
{/category}

查询共享栏目的指定id为1,2,3,4的栏目

{category module=share id=1,2,3,4}
栏目名称{$t.name}
栏目地址{$t.url}
{/category}


两级循环显示栏目(先循环父栏目,再循环其子栏目)如果有三级栏目,以此类推

{category module=share pid=0 return=c1}
    我是父栏目:{$c1.name}<br>
    {category module=share pid=$c1.id return=c2}
        我是{$c1.name}的子栏目:{$c2.name}<br>
    {/category}
{/category}


内容栏目封面模板category.html 调用指定栏目下的所有子栏目

<li><a href=""></a> {dr_catpos($catid, '', true, '<a href="[url]">[name]</a> ')}</li>  获取本栏目封面的名字和链接

pid=指定栏目的id
 {category module=share pid=3 return=c1}
   <li><a href="{$c1.url}">{$c1.name}</a></li>
  {/category}


最终效果

image



查询共享栏目中的属性配置

{category module=share more=1}
栏目名称{$t.name}
栏目属性seo标题{$t['setting']['seo']['list_keywords']}
{/category}


判断此栏目是否是外链栏目

{category module=share}
栏目名称{$t.name}
{if $t.tid==2}
外链栏目
{/if}
{if $t.tid==1}
内容模块栏目
{/if}
{if $t.tid==0}
单页栏目
{if}
{/category}


评论