phpcms常用调用方法

// 调用栏目下所有子目录名称及文章

{pc:content action="category" catid="$catid" num="10" order="listorder ASC"}
{loop $data $cat}
  {pc:content  action="lists" catid="$cat['catid']" order="id DESC" num="6" return="subcate"}
    {if $subcate}

        // 调用主栏目
        <h3>{$cat['catname']}</h3>

        // 调用主栏目下子目录3个
        {pc:content action="category" catid="$cat[catid]" num="3" siteid="$siteid" order="listorder ASC"}
          {loop $data $v}
            <span><a href="#">{$v[catname]}</a></span>
          {/loop}
        {/pc}

        // 调用主栏目(子目录)下文章
        <div class="i-main">
            <dl class="on">
                {loop $subcate $r}
                  <dd><a href="{$r[url]}" title="{$r[title]}" target="_Self">{$r['title']}</a></dd>
                {/loop}
            </dl>
        </div>

    {/if}
  {/pc}
{/loop}
{/pc}

// 导航调用

{pc:content action="category" catid="0" num="10" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<dl>
    <dt><a href="{$r[url]}" title="{$r[catname]}">{$r[catname]}</a></dt>

    // 判断是否有子栏目
    {if $r[child]}

    // 输出主栏目下的子栏目
    {pc:content action="category" catid="$r[catid]" num="15" siteid="$siteid" order="listorder ASC" return="data2"}
      {loop $data2 $v}
        <dd><a href="{$v[url]}" title="{$v[catname]}">{$v[catname]}</a></dd>
      {/loop}
    {/pc}

    {/if}
</dl>
{/loop}
{/pc}

// 调用全站最新文章

{pc:get sql="select * from v9_news where status=99 order by inputtime desc" num="10" }
  {loop $data $r}
    <li class="num1">
      <em class="color_{$n}">{$n}.</em>
      <a href="{$r[url]}" title="{$r[title]}" target="_Self">{$r[title]}</a>
    </li>
  {/loop}
{/pc}

// 调用全站推荐的文章 (适合轮播图)

{pc:content  action="position"  posid="2"  order="id DESC"  num="3"}
  {loop $data $key $val}
      <li>
        <a title="{$val[title]}" href="{$val[url]}">
        <img alt="{$val[title]}" src="{$val[thumb]}"></a>
      </li>
  {/loop}
{/pc}

// 调用全站点击最多的文章

{pc:get sql="select url,title,inputtime,dayviews FROM v9_news,v9_hits WHERE CONCAT('c-1-',v9_news.id)=v9_hits.hitsid order by weekviews desc" num="10" siteid="$siteid"}
  {loop $data $r}
      <li class="hot{$n}">
        <b>{$n}</b>
        <a href="{$r[url]}" target="_Self" title="{$r[title]}">{str_cut($r[title],43)}</a>
      </li>
  {/loop}
{/pc}

// 调用全站标签

{pc:get sql="SELECT keyword FROM `v9_keyword` WHERE length(`keyword`) > 2 ORDER BY `videonum` DESC" num="10"}
  {loop $data $r}
  {php $num++}
    <a href="{APP_PATH}index.php?m=content&c=tag&a=lists&tag={$r[keyword]}" target="_Self" title="{$r[keyword]}">{$r[keyword]}</ a>
  {/loop}
{/pc}

// 随机调用全站文章

{pc:get sql="select * from v9_news where status=99 order by id desc" num="6"}
  {loop $data $r}
      <li>
        <a href="{$r[url]}" title="{$r[title]}"><span>{$r[title]}</span>
        <img alt="{$r[title]}" src="{$r[thumb]}" width="158"></a>
      </li>
  {/loop}
{/pc}

// 调用当前栏目最新的文章

{pc:content action="lists" catid="$catid" num="10" order="inputtime desc"}
  {loop $data $r}
      <li class="hot{$n}">
        <b>{$n}</b>
        <a href="{$r[url]}" target="_Self" title="{$r[title]}">{str_cut($r[title],43)}</a>
      </li>
  {/loop}
{/pc}

 // 【 列表页 】  调用当前栏目的文章

{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page" }
{loop $data $r}
// 获取标签
    {php $keywords = explode(' ',$r[keywords]);}
    <li>
      <div class="art-img">
       <a href="{$r[url]}" target="_Self" title="{$r[title]}"><img alt="{$r[title]}" src="{$r[thumb]}" width="250"></ a>
      </div>
      <span class="art-name"><a href="{$r[url]}" target="_Self" title="{$r[title]}">{$r[title]}</a></span>
      <p>{$r[description]}</p >

      <span class="art-tags"><em>标签:</em>
        {loop $keywords $keyword}
          <a href="#" target="_Self" >{$keyword}</ a>
        {/loop}
      </span>

      <span class="art-person"><i class="art-time">{date('Y-m-d',$r[inputtime])}</i>  // 获取时间
      <i class="art-author">编辑:admin</i></span>
    </li>
{/loop}
{/pc}

// 内容页

当前位置:< a href="{WEB_PATH}">主页</ a> &gt; < a href="{siteurl($siteid)}" title="">{catpos($catid)}</ a>

 标题:{$title}

 获取文章时间:{$inputtime}

 分页:{$pages}

 // 浏览次数

 <i class="art-liu">浏览:<font id="hits"></font>次</i>

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

内容:{$content}

<p class="art-pre">上一篇:< a href='{$next_page[url]}' title='{$next_page[title]}'>{$next_page[title]}</ a></p >

<p class="art-next">下一篇:< a href='{$previous_page[url]}' title='{$previous_page[title]}'>{$previous_page[title]}</ a></p >

内容标题分页:{if ($page) > (1)}【{$page}】{/if}     (例:标题(2))

// URL设置规则

// 自己设置,感觉还可以... 规则:主域 / 主栏目 / 子栏目 / 内容页

主栏目:{$categorydir}{$catdir}/index.html|{$categorydir}{$catdir}/page/{$catdir}_{$page}.html

子栏目:{$categorydir}{$catdir}/index.html|{$categorydir}{$catdir}/index_{$page}.html

内容页:{$categorydir}{$catdir}/{$id}.html|{$categorydir}{$catdir}/{$id}_{$page}.html

{$CATEGORYS[$catid][url]}          显示当前栏目链接

{$CATEGORYS[$catid][catname]}      显示当前栏目名称

{str_cut($r[title],30)}            限制标题显示字符

{str_cut($r[description],112)}     限制截取的标题


上一篇:phpcms v9 实现首页,列表页,内容页调用点击量方法

下一篇:第一页