首页 > 代码库 > phpcms基本语句的用法

phpcms基本语句的用法

最近在做企业站,这里将phpcms里的常用语句总结一下:

1、头部:

<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />

<title>{if isset($SEO[title]) && !empty($SEO[title])}{$SEO[title]}{/if}{$SEO[site_title]}</title>

<meta name="keywords" content="{$SEO[‘keyword‘]}">

<meta name="description" content="{$SEO[‘description‘]}">

2、常用系统常量: {CSS_PATH} {JS_PATH} {IMG_PATH} {APP_PATH}//程序目录

3、头尾替换:

{template "content","header"}

{template "content","footer"}

4、常用调用数据:

{pc:content action="lists" catid="6" num="8" order="inputtime DESC" }

{loop $data $r}

<li><span class="date">({date(Y/m/d H:m:s,$r[inputtime])})</span><a href=http://www.mamicode.com/"{$r[url]}" target="_blank" title="{$r[title]}">{str_cut($r[title],28)}</a></li>

{/loop}

{/pc}

5、推荐位调用:

{pc:content action="position" posid="1" order="listorder DESC" num="5"}

{loop $data $r}

<li><a href=http://www.mamicode.com/"{$r[url]}" target="_blank"><img src=http://www.mamicode.com/"{$r[thumb]}" text="{$r[title]}" alt="{$r[title]}" width="727" height=243 /></a></li>

{/loop}

{/pc}

6、一级栏目调用:

{pc:content action="category" catid="0" num="8" siteid="$siteid" order="listorder ASC"}

{loop $data $r}

<li><a href=http://www.mamicode.com/"{$r[url]}" title="{$r[catname]}">{$r[catname]}</a></li>

{/loop}

{/pc}

7、文章列表页调用关键字,或者首页调用关键字::

{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"}

{loop $data $r}

<a href=http://www.mamicode.com/"{$r[url]}">{$r[title]}</a>

php $keywords = explode(,,$r[keywords]);}

<b>文章标签:</b>

{loop $keywords $keyword}

<a href=http://www.mamicode.com/"{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}" class="blue"> {$keyword}</a>

{/loop}

{/loop}

{/pc}

8、判断是否为首页:

{if $top_parentid==0}
//首页地址
<a href=http://www.mamicode.com/"{siteurl($siteid)}"><div class="menu menu_sel">首页</div></a>
{else}
<a href=http://www.mamicode.com/"{siteurl($siteid)}"><div class="menu">首页</div></a>
{/if}

9、取浏览数:

span id="hits"></span><!--浏览数的js-->
<script language="JavaScript" src=http://www.mamicode.com/"{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>

10、友情链接:

{pc:link action="type_list" typeid="0" siteid="1" linktype="1" order="listorder DESC" num="8"}

{loop $data $v}

<a href=http://www.mamicode.com/"{$v[‘url‘]}" title="{$v[‘name‘]}" target="_blank">{$v[name]}</a>

{/loop}

{/pc}

11、调用单页内容:

pc:get sql="SELECT content FROM v9_page where catid=‘6‘" return="data"}

{loop $data $r}

{str_cut(strip_tags($r[content]), 160)}

{/loop}

{/pc}

12、显示上一页和下一页:

<strong>上一篇:</strong><a href=http://www.mamicode.com/"{$previous_page[url]}">{$previous_page[title]}</a><br />

<strong>下一篇:</strong><a href=http://www.mamicode.com/"{$next_page[url]}">{$next_page[title]}</a>

 

phpcms基本语句的用法