需求:使用zblog建站劝萤,官方的編輯器里有設(shè)置文章置頂類別(無渊涝,分類,首頁床嫌,全局)跨释,至于模板里只有一個(gè)判斷是否是置頂文章,并且我的模板里需要循環(huán)兩次厌处,如果使用單獨(dú)模板的方式需要分出去幾個(gè)模板鳖谈,只能另尋辦法,使用GetList函數(shù)最后得到想要的結(jié)果阔涉。
主要注意在首頁GetList的第二個(gè)參數(shù)null即可蚯姆,在欄目頁就要獲取到欄目當(dāng)前的ID了;
使用自定義查詢參數(shù)where_custom洒敏,查詢log_IsTop得到相應(yīng)置頂類別的值(0龄恋,1,2凶伙,4)從而正確獲取需求的列表郭毕。具體代碼說明如下圖:
完整的代碼貼出:
{$topArray = GetList(3, $category->ID, null, null, null, null, array('where_custom' => array(array('=', 'log_IsTop', 4))));}
{if $topArray}
<section id="cateSlideBox" class="txtScroll-left">
<div class="hd">
<a class="next"></a>
<ul class="num">
{foreach $topArray as $key=>$top}<li>{$key+1}</li>{/foreach}
</ul>
<a class="prev"></a>
</div>
<div class="bd">
<ul class="infoList">
{foreach $topArray as $top}
<li>
<a href="{$top.Url}" target="_blank" title="{$top.Title}">{getDes($top->Title,20)}</a>
<!--span>{$top->Time('UpdateTime','m-d')}</span-->
</li>
{/foreach}
</ul>
</div>
</section>
{/if}