PHPCMS調用一級欄目二級欄目及下屬內容的方法
來源:程序員人生 發布時間:2014-01-16 22:03:08 閱讀次數:3974次
一級欄目:湖北 湖南 上海 北京
每個一級欄目下面都有個二級欄目“新聞動態”對應的ID分別是:71,72,73,74
我現在想讓它這樣顯示:
湖北 新聞動態 這里是湖北新聞動態1 2010-1-10
湖南 新聞動態 這里是湖南新聞動態13 2010-1-10
湖南 新聞動態 這里是湖南新聞動態19 2010-1-10
上海 新聞動態 這里是上海新聞動態17 2010-1-10
北京 新聞動態 這里是北京新聞動態2 2010-1-10
上海 新聞動態 這里是上海新聞動態13 2010-1-10
湖北 新聞動態 這里是湖北新聞動態11 2010-1-10
調用方法:
<ul class="text_list">
{get sql="select title,url,catid,updatetime from phpcms_content where status=99 and catid in(71,72,73,74) order by rand() desc" rows="3"}
<li>
{catpos($CATEGORY[$r[catid]][parentid])}----<a href="{$CATEGORY[$r[catid]][url]}" class="catname">{$CATEGORY[$r[catid]][catname]}----<span class="date">{date('Y-m-d',$r[updatetime])}</span> <a href="{$r[url]}" title="{$r[title]}" target="_blank">{str_cut($r[title], 40,'')} </a>
</li>
{/get}
</ul>