phpcms代码读取文章的内容 实用可行的方法

在使用phpcms做网站的时候经常遇到读取网站的内容作为推荐,而不是描述。这里使用可行的方法交你如何读取内容推荐。方法有两个,第一种执行的效率低,第二个效率高些。

    1、 {pc:get sql="select * from v9_news_data where id=$r[id]" return="newsdata" catid="7" order="id" num="1" cache="3600"}

                                {loop $newsdata $r}

 <div class="info">{str_cut($r['content'],128)}

...<a href="{$r[url]}" target="_blank">[详情]</a></div>

                                   {/loop}

                                {/pc}

 

2、直接加  moreinfo="1"    {pc:content  moreinfo="1" action="lists" catid="7" order="id" num="1" cache="3600"}

                                {loop $data $r}

 <div class="info">{str_cut($r['content'],128)}

...<a href="{$r[url]}" target="_blank">[详情]</a></div>

                                   {/loop}

                                {/pc}

 

其中catid是对应你的栏目ID num是个数

 

 

posted @ 2017-02-23 09:20  黄力军  阅读(1034)  评论(0编辑  收藏  举报