最详细的的phpcms v9模版调用代码(新手必看教程)

jerry CMS 2015年08月09日 收藏

首页调用栏目

{pc:content action="category" siteid="$siteid" num="15" order="listorder"}
     {loop $data $r}
        <li><a title="" href="{$r}">{$r[catname]}</a></li>
     {/loop}
{/pc}

调用二级栏目

{pc:content action="category" catid="7" num="20" order="listorder"}
      {loop $data $r}
         <a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[catname]}</a>
      {/loop}
{/pc}

判断当前栏目是否存在子栏目

{if $v[child]==1} 
XXX 
{else} 
XXX 
{/if}

调用文章列表

{pc:content action="lists" catid="25" num="8" order="id desc"}
     {loop $data $r}
          <li><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></li>
     {/loop}
{/pc}

带缩略图:

{pc:content action="lists" catid="20" order="id desc" num="6"}
      {loop $data $r}
          <div class="tuphp">
              <h4><a href="{$r[url]}" target="_blank" title="{$r[title]}">
             
 <img src="{thumb($r['thumb'],111,139)}" alt="{$r[title]}" width="" 
height=""  border="0"></a></h4>
              <p><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></p>
          </div>
      {/loop}
{/pc}

调用推荐位

{pc:content action="position" posid="2" order="listorder" num="1"}
     {loop $data $r}
         <div class="abti"><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></div>
         <div class="aboutcon"> <img src="statics/dimages/2010111758232601.jpg">{str_cut($r[description],106)}
         <div style="clear:both;"></div>
         </div>
        
 <div class="abobtn"><a href="{$r[url]}" target="_blank" 
title=""><img 
src="statics/dimages/abobtn.jpg"></a></div>
     {/loop}
{/pc}

sql方法调用

{pc:get sql="SELECT * FROM v9_news WHERE catid <= 50 and catid >= 1  order by id DESC" return="data" num="6" start="0"  }
             {loop $data $r}
               
 <li><a href="{$r[url]}" target="_blank" class="lef" 
title="{$r[title]}">{str_cut($r[title],35,'')}</a><span>[{date('Y-m-d',$r[inputtime])}]</span></li>
             {/loop}
{/pc}

调用相关文章

{pc:content action="relation" relation="$relation" catid="2" num="5" keywords="$rs[keywords]"}
{loop $data $r}
{$r[title]}
{/loop}
{/pc}

内容页相关文章的点击量

{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"} 
     {loop $data $r}
        <p>
       
 <li><a href="{$r[url]}" target="_blank"><img 
src="/NanJing454/statics/nimages/next1.png" /> {str_cut($r[title], 
57)}</a>{php 
$h_md=pc_base::load_model('hits_model');$get_db=$h_md->get_one(array('hitsid'=>"c-".$modelid."-".$r[id]));$views=$get_db[views];}
          点击量:{$views} </li>
        </p>
     {/loop}
{/pc}

全站最新文章

{pc:content action="newcontent" order="8" num="7"}
     {loop $data $r}
        <li>[{$CATEGORYS[$r[catid]][catname]}]<a href="{$r['url']}">{str_cut($r['title'],28)}</a></li>
     {/loop}
{/pc}

合作机构:

{pc:link action="type_list" linktype="1" siteid="$siteid" typeid="53" num="16" order="listorder DESC"}
      {loop $data $r}
              <img src="{$r['logo']}" border="0" />
      {/loop}
{/pc}

友情链接:

{pc:link  action="type_list" siteid="$siteid"  typeid="53" order="listorder DESC" num="60" return="dat"}
    {loop $dat $v}
         <a href="{$v[url]}" target="_blank" title="{$v[name]}">{$v[name]}</a> 
    {/loop}
{/pc}

字符截取

{str_cut($r[title],30,'')}

列表页调父栏目子栏目

{php $arrchildid = $CATEGORYS[$CAT[parentid]][catid]}
                    {pc ...  catid="$arrchildid"}

内页时间:

{date('Y-m-d',strtotime($inputtime))}

导航条当前位置

》》<a href="{siteurl($siteid)}"> 首页 
</a>》》<font color="#6C4833"> {catpos($catid)} 
{$title}</font>

上一篇:

<a href="{$previous_page[url]}">{str_cut($previous_page[title], 30)}</a>

下一篇:

<a href="{$next_page[url]}">{str_cut($next_page[title], 30)}</a>

时间:

date('Y-m-d',$r[inputtime])}

内容页调取浏览次数:

</span><span id="hits"><script language="JavaScript" 
src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script></span>

列表页调取浏览次数

{php $db = pc_base::load_model(‘hits_model’); $_r = 
$db->get_one(array(‘hitsid’=>’c-’.$modelid.’-’.$r[id])); $views = 
$_r[views]; }

点击:

{$views}

列表页调关键词:                

 {php $keywords=explode(' ', $r['keywords'])}
                                  {loop $keywords $keyword}
                                      
 <a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}"
 class="blue">{$keyword}</a>&nbsp;
  {/loop}

内页调关键词:

{loop $keywords $keyword}
<a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}"
 class="blue">{$keyword}</a>         
{/loop}

加载附表

 moreinfo="1"

js获取时间

      <script>
var x = new Date();
    var shijian = x.toLocaleString().substring(0,10) ;
    document.write(shijian);
</script>

调用单网页

{pc:get sql="SELECT * FROM phpcms_page where catid=16" cache="3600" return="data"}
    {loop $data $r}
      <div id="Article">
            <h1>{$r[title]}</h1>
        <div class="content">
                {$r[content]}
        </div>
    </div>
    {/loop}
{/pc}

栏目页循环栏目

{loop subcat($catid) $v}
            {php if($v['type']!=0) continue;}
            <div class="main_list_box">
              <div class="list_tit">
                <h5><em></em> {$v[catname]}</h5>
                <a href="{$v[url]}" class="more">更多</a></div>
              <ul class="main_list_ul">
                {pc:content action="lists" catid="$v[catid]" num="4" order="id DESC"}
                {loop $data $r}
               
 <li><span><a href="{$r[url]}">{$r[title]} 
</a></span><em>{date('Y-m-d',$r[inputtime])}</em></li>
                {/loop}
                {/pc}
              </ul>
            </div>
            {$j++}
            {php if ($j>=7) break;}
{/loop}

栏目名调用:

$CATEGORY[$catid][catid]                栏目id   
$CATEGORY[$catid][module]                栏目所在的模块   
$CATEGORY[$catid][type]                        栏目类型   
$CATEGORY[$catid][modelid]                栏目所属模型id   
$CATEGORY[$catid][catname]                栏目名称   
$CATEGORY[$catid][style]                栏目名称样式   
$CATEGORY[$catid][image]                栏目图片   
$CATEGORY[$catid][catdir]                栏目路径   
$CATEGORY[$catid][url]                        目录url   
$CATEGORY[$catid][parentid]                栏目的父id   
$CATEGORY[$catid][arrparentid]        所有上级栏目ID   
$CATEGORY[$catid][parentdir]        父栏目的路径   
$CATEGORY[$catid][child]                是否有子栏目   
$CATEGORY[$catid][arrchildid]        栏目的所有子栏目id   
$CATEGORY[$catid][items]                栏目信息数    
$CATEGORY[$catid][ismenu]                栏目是否显示导航  
$CATEGORY[$catid][catid]                栏目id
$CATEGORY[$catid][module]                栏目所在的模块
$CATEGORY[$catid][type]                        栏目类型
$CATEGORY[$catid][modelid]                栏目所属模型id
$CATEGORY[$catid][catname]                栏目名称
$CATEGORY[$catid][style]                栏目名称样式
$CATEGORY[$catid][image]                栏目图片
$CATEGORY[$catid][catdir]                栏目路径
$CATEGORY[$catid][url]                        目录url
$CATEGORY[$catid][parentid]                栏目的父id
$CATEGORY[$catid][arrparentid]        所有上级栏目ID
$CATEGORY[$catid][parentdir]        父栏目的路径
$CATEGORY[$catid][child]                是否有子栏目
$CATEGORY[$catid][arrchildid]        栏目的所有子栏目id
$CATEGORY[$catid][items]                栏目信息数 
$CATEGORY[$catid][ismenu]                栏目是否显示导航

搜索页调用栏目名

{pc:get sql="select * from v9_category where catid='$r[catid]'" num="1" return="da"}
  {loop $da $v}
       <a href="{$v[url]}" >{$v[catname]}</a>
  {/loop}
{/pc}