PHPCMS 2008 SP3 模板语法规则整理

2024-05-05 02:32

本文主要是介绍PHPCMS 2008 SP3 模板语法规则整理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、模板语法规则 


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 
本篇文章来源于源码库(www.aspku.com),转载请注明出处 原文链接:http://www.aspku.com/cms/phpcms/3835.html

这篇关于PHPCMS 2008 SP3 模板语法规则整理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/960627

相关文章

Redis分片集群、数据读写规则问题小结

《Redis分片集群、数据读写规则问题小结》本文介绍了Redis分片集群的原理,通过数据分片和哈希槽机制解决单机内存限制与写瓶颈问题,实现分布式存储和高并发处理,但存在通信开销大、维护复杂及对事务支持... 目录一、分片集群解android决的问题二、分片集群图解 分片集群特征如何解决的上述问题?(与哨兵模

Python变量与数据类型全解析(最新整理)

《Python变量与数据类型全解析(最新整理)》文章介绍Python变量作为数据载体,命名需遵循字母数字下划线规则,不可数字开头,大小写敏感,避免关键字,本文给大家介绍Python变量与数据类型全解析... 目录1、变量变量命名规范python数据类型1、基本数据类型数值类型(Number):布尔类型(bo

MyBatis Plus 中 update_time 字段自动填充失效的原因分析及解决方案(最新整理)

《MyBatisPlus中update_time字段自动填充失效的原因分析及解决方案(最新整理)》在使用MyBatisPlus时,通常我们会在数据库表中设置create_time和update... 目录前言一、问题现象二、原因分析三、总结:常见原因与解决方法对照表四、推荐写法前言在使用 MyBATis

C++作用域和标识符查找规则详解

《C++作用域和标识符查找规则详解》在C++中,作用域(Scope)和标识符查找(IdentifierLookup)是理解代码行为的重要概念,本文将详细介绍这些规则,并通过实例来说明它们的工作原理,需... 目录作用域标识符查找规则1. 普通查找(Ordinary Lookup)2. 限定查找(Qualif

MySQL复杂SQL之多表联查/子查询详细介绍(最新整理)

《MySQL复杂SQL之多表联查/子查询详细介绍(最新整理)》掌握多表联查(INNERJOIN,LEFTJOIN,RIGHTJOIN,FULLJOIN)和子查询(标量、列、行、表子查询、相关/非相关、... 目录第一部分:多表联查 (JOIN Operations)1. 连接的类型 (JOIN Types)

Nginx Location映射规则总结归纳与最佳实践

《NginxLocation映射规则总结归纳与最佳实践》Nginx的location指令是配置请求路由的核心机制,其匹配规则直接影响请求的处理流程,下面给大家介绍NginxLocation映射规则... 目录一、Location匹配规则与优先级1. 匹配模式2. 优先级顺序3. 匹配示例二、Proxy_pa

JAVA数组中五种常见排序方法整理汇总

《JAVA数组中五种常见排序方法整理汇总》本文给大家分享五种常用的Java数组排序方法整理,每种方法结合示例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录前言:法一:Arrays.sort()法二:冒泡排序法三:选择排序法四:反转排序法五:直接插入排序前言:几种常用的Java数组排序

Java如何根据word模板导出数据

《Java如何根据word模板导出数据》这篇文章主要为大家详细介绍了Java如何实现根据word模板导出数据,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... pom.XML文件导入依赖 <dependency> <groupId>cn.afterturn</groupId>

Nginx路由匹配规则及优先级详解

《Nginx路由匹配规则及优先级详解》Nginx作为一个高性能的Web服务器和反向代理服务器,广泛用于负载均衡、请求转发等场景,在配置Nginx时,路由匹配规则是非常重要的概念,本文将详细介绍Ngin... 目录引言一、 Nginx的路由匹配规则概述二、 Nginx的路由匹配规则类型2.1 精确匹配(=)2

Spring Boot 常用注解整理(最全收藏版)

《SpringBoot常用注解整理(最全收藏版)》本文系统整理了常用的Spring/SpringBoot注解,按照功能分类进行介绍,每个注解都会涵盖其含义、提供来源、应用场景以及代码示例,帮助开发... 目录Spring & Spring Boot 常用注解整理一、Spring Boot 核心注解二、Spr