調用當前欄目推薦文章的辦法

{pc:content action="position" posid="10" catid="$catid" num="20" order="id DESC" cache="3600"}sql

{loop $data $r}oop

<p class="list"><a href="{$r[url]}" title="{$r[title]}">{$r[title]}</a></p>字體

{/loop}url

{/pc}spa

 

調用當前欄目推薦文章的辦法

 

可是隻能調用一個屬性的推薦位,若是有時候須要調用所有推薦位的又該怎麼弄呢?今天就教你們怎麼實現吧!下面的標籤便可實現只要勾了推薦位的文章都給調用出來噢!get

 

{pc:get sql="SELECT `url`,`title` FROM `v9_dede_article` where `posids`<>0 AND `catid`=$catid ORDER BY `v9_dede_article`.`inputtime` DESC" num="15"}input

<div class="alltitle f16 bold"><span>{$CATEGORYS[$catid][catname]}推薦文章</span></div>it

<div class="clearfix content">io

<ul>class

{loop $data $r}

<li class="height25 line-height25 ico_grey hidden"><a href="{$r[url]}"{if $r['style']}{title_style($r[style])}{/if}title="{$r[title]}">{$r[title]}</a></li>

{/loop}

</ul>

</div>

{/pc}

 

較真的盆友可能會問,那要是文章所有都是沒有勾推薦位豈不是沒有數據而空白了麼?OK,咱們再完善成當沒有的時候就調用當前欄目的最新文章吧!

 

{pc:get sql="SELECT `url`,`title` FROM `v9_dede_article` where `posids`<>0 AND `catid`=$catid ORDER BY `v9_dede_article`.`inputtime` DESC" num="15"}

{if $data}

<div class="alltitle f16 bold"><span>{$CATEGORYS[$catid][catname]}推薦文章</span></div>

<div class="clearfix content">

<ul>

{loop $data $r}

<li class="height25 line-height25 ico_grey hidden"><a href="{$r[url]}"{if $r['style']}{title_style($r[style])}{/if}title="{$r[title]}">{$r[title]}</a></li>

{/loop}

</ul>

</div>

{else}

{pc:content  action="lists" catid="$catid" num="15" order="inputtime DESC" cache="3600"}

<div class="alltitle f16 bold"><span>{$CATEGORYS[$catid][catname]}最新文章</span></div>

<div class="clearfix content">

<ul>

{loop $data $r}

<li class="height25 line-height25 ico_grey hidden"><a href="{$r[url]}"{if $r['style']}{title_style($r[style])}{/if}title="{$r[title]}">{str_cut($r[title], 400, '..')}</a></li>

{/loop}

</ul>

</div>

{/pc}

{/if}

{/pc}

 

注意上面紅色字體 {$CATEGORYS[$catid][catname]}  的意思是當前欄目的名字。

相關文章
相關標籤/搜索