Home >CMS Tutorial >PHPCMS >How to use phpcms tag?
Usage of phpcms tag: 1. Display the column name and link of the specified catid; 2. Call the sub-column; 3. Get the news under the specified column; 4. Implement the paging function.
Usage of phpcms tag:
1. Display the column name and link of the specified catid {$CATEGORYS[25]['catname']} {$CATEGORYS[25]['url']}
Get the parent column id, get the parent column name $CATEGORY[$catid][ parentid]}
Parent column name: {$CATEGORYS[$CAT[parentid]][catname]}
The ellipsis that appears after removing the title restriction
{str_cut($r[title],36,'...')}
Formatting time 2011-05-06 11:22:33
{date('Y-m-d H:i:s',$r[inputtime])} {date('Y年m月d日',$r[inputtime])}
2. Call sub-column (need to be used in the column homepage template, and can also be used in the list page)
{pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorder ASC"} {loop $data $r} <a href="{$r[url]}">{$r[catname]}</a> | {/loop}{/pc}
3. Get the news under the specified column
(1) Here moreinfo="1" means that the main and secondary tables can be related directly using
{pc:content action="lists" catid="$catid" num="25" order="id DESC" return="info" moreinfo="1"} {loop $info $r} 更新日期:{date('Y年m月d日',$r[updatetime])} 作者:{$r[username]} 来源:{$r[copyfrom]} 点击率{$r[readpoint]} 网址{$r[url]} 文章标题 {$r['title']} 标题样式{title_style($v[style])} {/loop} {/pc} <p>=====================</p
( 2) The sql universal statement can call the specified content more conveniently
{pc:get sql="select * from v9_news as a,v9_news_data as b where a.id=b.id and catid=34 and status=99 order by a.id desc"} {loop $data $v} <li><a href="{$v['url']}" target="_blank"><img src="{$v[thumb]}" width="146" height="117" /></a></li> {/loop} {/pc} {pc:get sql="select * from v9_news where catid=10 and status=99 order by updatetime desc" num="5" start="23"} {loop $data $rs} <a href="{$rs['url']}" title="{$rs['title']}" target="_blank">{$rs['title']}</a> {/loop} {/pc} <p>=====================</p
(3) The article is called from the specified position (position is recommended)
The starting position is 5, and 3 articles are called. Equivalent to the limit function.
{pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"} {loop $info $r} <a href='{$r[url]}'>{str_cut($r[description],115)}... </a> {/loop} {/pc} 或{pc:content action="lists" catid="54" thumb="" order="listorder DESC" start="3" num="5"} thumb="" 不分类 <p>=====================</p>循环列表新闻 <div class="content"> {pc:content action="position" posid="9" order="listorder DESC" num="4"} {loop $data $r} <a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a>{date('Y-m-d H:i:s',$r[inputtime])} <p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112,'')}<a href="{$r[url]}">[reading more]</a></p> {/loop} {/pc} </div> <p>=====================</p>
(4) There is a paging effect
{pc:get sql="select * from wecheweyounews where hour=$hour order by id desc" return="data" num="50" page="$page"} <ul > {loop $data $r} <li><span class="left">·<a href="{$r['url']}" target="_blank">{str_cut($r['title'],60)}</a>(编辑:{$r[username]})</span><span class="right">{date("Y-m-d",$r['inputtime'])}</span></li></li> <?php if($n%5==0 and $n<50) echo "</ul><ul>"; ?> {/loop} </ul> </div> <div id="pages" class="text-c">{$pages}</div> {/pc}
4. ff0c61d053e31b769184a7753e7bd4ac
{pc:content action="position" posid="1" order="listorder DESC" thumb="1" num="5"} {loop $data $r} <a href="{$r['url']}" title="{str_cut($r['title'],30)}"><img src="{thumb($r['thumb'],300,200)}" alt="{$r['title']}" width="310" height="260" /></a> {/loop} {/pc}
5. Paging
The front desk call num="50" refers to 50 records per page
{pc:get sql="select * from wecheweyounews where hour=$hour order by id desc" return="data" num="50" page="$page"} <ul > {loop $data $r} <li><span class="left">·<a href="{$r['url']}" target="_blank">{str_cut($r['title'],60)}</a>(编辑:{$r[username]})</span><span class="right">{date("Y-m-d",$r['inputtime'])}</span></li></li> <?php if($n%5==0 and $n<50) echo "</ul><ul>"; ?> {/loop} </ul> </div> <div id="pages" class="text-c">{$pages}</div> {/pc}
Related learning recommendations : phpcms tutorial
The above is the detailed content of How to use phpcms tag?. For more information, please follow other related articles on the PHP Chinese website!