Home > CMS Tutorial > PHPCMS > body text

How to use phpcms tag?

coldplay.xixi
Release: 2020-07-14 13:20:11
Original
3020 people have browsed it

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.

How to use phpcms tag?

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,'...')}
Copy after login

Formatting time 2011-05-06 11:22:33

    {date('Y-m-d H:i:s',$r[inputtime])}
    {date('Y年m月d日',$r[inputtime])}
Copy after login

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}
Copy after login

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(&#39;Y年m月d日&#39;,$r[updatetime])}
             作者:{$r[username]}
             来源:{$r[copyfrom]}
             点击率{$r[readpoint]}
             网址{$r[url]}
             文章标题 {$r[&#39;title&#39;]}
             标题样式{title_style($v[style])}
                      
    {/loop}
    {/pc}
<p>=====================</p
Copy after login

( 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[&#39;url&#39;]}" 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[&#39;url&#39;]}" title="{$rs[&#39;title&#39;]}" target="_blank">{$rs[&#39;title&#39;]}</a>
     {/loop}
 {/pc}
<p>=====================</p
Copy after login

(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=&#39;{$r[url]}&#39;>{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,&#39;&#39;)}</a>{date(&#39;Y-m-d H:i:s&#39;,$r[inputtime])}
                <p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112,&#39;&#39;)}<a href="{$r[url]}">[reading more]</a></p>
               
               {/loop} 
             {/pc}  
            </div>
<p>=====================</p>
Copy after login

(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">&middot;<a href="{$r[&#39;url&#39;]}" target="_blank">{str_cut($r[&#39;title&#39;],60)}</a>(编辑:{$r[username]})</span><span class="right">{date("Y-m-d",$r[&#39;inputtime&#39;])}</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}
Copy after login
Copy after login

4.

{pc:content  action="position" posid="1"  order="listorder DESC" thumb="1" num="5"}
 {loop $data $r}
  <a href="{$r[&#39;url&#39;]}" title="{str_cut($r[&#39;title&#39;],30)}"><img src="{thumb($r[&#39;thumb&#39;],300,200)}" alt="{$r[&#39;title&#39;]}" width="310" height="260" /></a>
    {/loop}
    {/pc}
Copy after login

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">&middot;<a href="{$r[&#39;url&#39;]}" target="_blank">{str_cut($r[&#39;title&#39;],60)}</a>(编辑:{$r[username]})</span><span class="right">{date("Y-m-d",$r[&#39;inputtime&#39;])}</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}
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!