PHPCMS 2008 SP3 模板语法规则整理

所属分类: CMS教程 / phpcms 阅读数: 682
收藏 0 赞 0 分享
一、模板语法规则

1、变量表示
{$name} 被解析成 <?=$name?>,表示显示变量$name的值,其中的“name”由英文字母、数字和下划线组成首字母必须是英文字母或者下划线。

2、常量表示
{name}被解析成<?=name?>,表示显示常量name的值,其中的“name”由英文字母、数字和下划线组成首字母必须是英文字母或者下划线。

3、条件判断
{if *} * {else} * {else} * {/if} 或者 {if *} * {/if},其中{if *}中的*就是此判断语句的条件表达式,符合php的表达式。

{if $userid} {$username}{else} {$noname}{/if}

4、循环
{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop} ,{loop $a $b} * {/loop}

被解析成 <? if(is_array($a)) foreach($a AS $b) { ?> * <? } ?>

而 {loop $a $b $c} * {/loop} 则被解析成 <? if(is_array($a)) foreach($a AS $b=>$c) { ?> * <? } ?>

5.模板包含
{template 'module name','file name'}例如: {template 'phpcms','header'}表示包含模板目录,phpcms目录下header.html文件
建议 if 和 loop 语法应该写在html注释符之间,这样可以避免在编辑工具中难看,例如:
这样写 if
<!--{if $a>$b}--> <!--{else}--> <!--{/if}-->
这样写 loop
<!--{loop $arr $key $val}--> <!--{/loop}-->

如果您不习惯这套语法,也可以直接在模板中书写php代码,例如<?php echo 'Hello World!';?>

二、模板制作常用变量

常用的系统变量

打开文件 ./include/common.inc.php

复制代码
代码如下:

IP //取得ip
TIME //取得时间戳,格式(1229393941 )可以通过date 函数格式化一个本地时间/日期,请参考php手册
URL //取得当前浏览的url地址
SITE_URL //网站的url地址
//以上是系统常量,直接调用,如()
$MODULE //系统模块信息
[MODULE][phpcms] =&gt; Array
(
[module] =&gt; phpcms
[name] =&gt; Phpcms
[path] =&gt;
[url] =&gt;
[iscore] =&gt; 1
[version] =&gt; 1.0.0.0
)
$MODEL //模型信息
[MODEL] =&gt; Array
(
[1] =&gt; Array
(
[modelid] =&gt; 1
[name] =&gt; 新闻
[description] =&gt;
[tablename] =&gt; news
[itemname] =&gt; 新闻
[itemunit] =&gt; 篇
[workflowid] =&gt; 1
[template_category] =&gt; category
[template_list] =&gt; list
[template_show] =&gt; show
[template_print] =&gt; print
[ishtml] =&gt; 1
[category_urlruleid] =&gt; 1
[show_urlruleid] =&gt; 7
[enablesearch] =&gt; 1
[ischeck] =&gt; 1
[isrelated] =&gt; 1
[disabled] =&gt; 0
[modeltype] =&gt; 0
)
)
$CATEGORY //栏目信息
[CATEGORY] =&gt; Array
(
[1] =&gt; Array
(
[catid] =&gt; 1
[module] =&gt; phpcms
[type] =&gt; 1
[modelid] =&gt; 0
[catname] =&gt; 网站介绍
[style] =&gt;
[image] =&gt;
[catdir] =&gt; about
[url] =&gt; /cms/phpcms_utf/about/index.html
[parentid] =&gt; 0
[arrparentid] =&gt; 0
[parentdir] =&gt;
[child] =&gt; 1
[arrchildid] =&gt; 1,2,3,4,5
[items] =&gt; 0
[ismenu] =&gt; 0
)
)
$TYPE //类型信息
[TYPE] =&gt; Array
(
[1] =&gt; Array
(
[typeid] =&gt; 1
[module] =&gt; link
[name] =&gt; 默认分类
[style] =&gt;
[typedir] =&gt;
[url] =&gt;
)
)
$AREA //地区信息
[AREA] =&gt; Array
(
[1] =&gt; Array
(
[areaid] =&gt; 1
[name] =&gt; 北京
[style] =&gt;
[parentid] =&gt; 0
[arrparentid] =&gt; 0
[child] =&gt; 0
[arrchildid] =&gt; 1
)
)
$URLRULE //url规则信息
[URLRULE] =&gt; Array
(
[1] =&gt; {$categorydir}/index.{$fileext}|{$categorydir}/{$page}.{$fileext}
[2] =&gt; category/{$catid}.{$fileext}|category/{$catid}_{$page}.{$fileext}
[3] =&gt; {$catdir}/index.{$fileext}|{$catdir}/{$page}.{$fileext}
[4] =&gt; list.php?catid={$catid}|list.php?catid={$catid}&amp;page={$page}
[5] =&gt; list.php?catid-{$catid}.html|list.php?catid-{$catid}/page-{$page}.html
[6] =&gt; list-{$catid}-{$page}.html
[7] =&gt; {$year}/{$month}{$day}/{$contentid}.{$fileext}|{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[8] =&gt; {$categorydir}/{$year}/{$month}{$day}/{$contentid}.{$fileext}|{$categorydir}/{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[9] =&gt; show/{$contentid}.{$fileext}|show/{$contentid}_{$page}.{$fileext}
[10] =&gt; show.php?contentid={$contentid}|show.php?contentid={$contentid}&amp;page={$page}
[11] =&gt; show.php?contentid-{$contentid}.html|show.php?contentid-{$contentid}/page-{$page}.html
[12] =&gt; show-{$contentid}-1.html|show-{$contentid}-{$page}.html
[13] =&gt; {$typedir}/index.{$fileext}|{$typedir}/{$page}.{$fileext}
[14] =&gt; {$typedir}.{$fileext}|{$typedir}_{$page}.{$fileext}
[15] =&gt; {$typeid}.{$fileext}|{$typeid}_{$page}.{$fileext}
[16] =&gt; list.php?typeid={$typeid}|list.php?typeid={$typeid}&amp;page={$page}
[17] =&gt; list.php?typeid-{typeid}.html|list.php?typeid-{typeid}/page-{$page}.html
[19] =&gt; {$typedir}/{$filename}.{$fileext}
[20] =&gt; {$typedir}_{$filename}.{$fileext}
[21] =&gt; {$filename}.{$fileext}
[22] =&gt; show.php?specialid={$specialid}
[23] =&gt; show.php?specialid-{$specialid}.html
[24] =&gt; show-{$specialid}.html
[25] =&gt; show-{$id}.html
[26] =&gt; ask/list-{$catid}-{$action}-1.html|ask/list-{$catid}-{$action}-{$page}.html
[27] =&gt; {$id}.html
[28] =&gt; show.php?id={$id}
)
$M //存储模块信息,在模块下想得到该模块的信息 可以直接使用$M
更多精彩内容其他人还在看

PHPCMS系统自带标签说明

关键字描述:说明 标签 系统 channelid 首页 专题 推荐 图片 文章 PHPCMS系统自带标签说明 首页最新文章列表 articlelist(0,1,0,1,0,0,10,46,0,0,0,1,2,0,0,0,1,1) 首页热点下载列表 downlist
收藏 0 赞 0 分享

phpcms语法规则

关键字描述:规则 语法   < if > loop name 字母 --> /loop 1、变量表示 {$name}被解析成<?=$name?>,表示显示变量$name的值,其中的“name&rdquo
收藏 0 赞 0 分享

phpcms将下载地址替换为图片显示

关键字描述:图片 显示 地址 下载
收藏 0 赞 0 分享

如何把PHPCMS的网站和数据库删除

关键字描述:删除 数据库 网站 如何 PHPCMS mysql 程序 修改 如果 如何把PHPCMS的网站和数据库删除 如果网站换空间了,原来的空间还保存着PHPCMS的mysql数据库,那我们怎么把他删除呢? 很简单 1.删除mysql数据库:通过PHPMYADMIN
收藏 0 赞 0 分享

phpcms关于标签和频道的基础概念

关键字描述:基础 概念 频道 标签 关于   调用 一个 文章 我们 phpcms一直是很多站长使用的建站系统,我们今天谈一下phpcms标签和频道的一些基础知识。 1、 何谓标签? phpcms 一直以来采用的是标签调用的方法,这样就能
收藏 0 赞 0 分享

PHPCMS网站转移空间教程

关键字描述:教程 空间 转移 网站 文件 目录 数据库   PHPCMS 有关phpcms网站转移空间,备份数据库转移空间的文章不是很多,所以就发表操作方法: 1.备份mysql数据库 现在的空间基本都有phpmyadmin 首先进入phpmyadm
收藏 0 赞 0 分享

phpcms常见问题解答

关键字描述:常见 频道 目录 建立 设置 ftp 标签   文章 可以 1.为什么phpcms首页幻灯片怎么显示不出来? 答:需要设置文章的 标题图片 如果设置标题图片,则可以在首页以及栏目页以图片方式链接到文章。 2.自定义phpcms的标签
收藏 0 赞 0 分享

phpcms如何使用水印功能

关键字描述:功能 使用 如何 水印 图片 字体 文字 需要 文件 中文 phpcms水印功能只有在添加标题图片的时候生成带水印的图片。 编辑器上传的图片不能增加水印和缩略图 添加水印功能: 1,首先查看服务器参数查看 图形处理 GD Library 这个选项是不
收藏 0 赞 0 分享

PHPCMS 模板安装导入教程

关键字描述:教程 导入 安装 模板 目录 更新 管理 依次 然后 方案 关于phpcms模板安装教程,导入模板的方法: 1.模板安装 下载已发布共享的模板文件包,解压后上传模板目录至templates目录下,进入后台模板风格 -〉方案管理(见下图),启
收藏 0 赞 0 分享

phpcms模仿QQ和MSN消息提示的效果

关键字描述:提示 效果 消息 模仿 " popTop if else & screen.width-2 你一定很喜欢像QQ或者MSN好友登录提示的效果吧,那么怎么样能在网页中实现呢?正好我在蓝色理想中发现了这段代码,贴出给大家看看(注意,如果使用以下代码,先
收藏 0 赞 0 分享
查看更多