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

相关文章

MyBatis的xml中字符串类型判空与非字符串类型判空处理方式(最新整理)

《MyBatis的xml中字符串类型判空与非字符串类型判空处理方式(最新整理)》本文给大家介绍MyBatis的xml中字符串类型判空与非字符串类型判空处理方式,本文给大家介绍的非常详细,对大家的学习或... 目录完整 Hutool 写法版本对比优化为什么status变成Long?为什么 price 没事?怎

Python 函数详解:从基础语法到高级使用技巧

《Python函数详解:从基础语法到高级使用技巧》本文基于实例代码,全面讲解Python函数的定义、参数传递、变量作用域及类型标注等知识点,帮助初学者快速掌握函数的使用技巧,感兴趣的朋友跟随小编一起... 目录一、函数的基本概念与作用二、函数的定义与调用1. 无参函数2. 带参函数3. 带返回值的函数4.

Python按照24个实用大方向精选的上千种工具库汇总整理

《Python按照24个实用大方向精选的上千种工具库汇总整理》本文整理了Python生态中近千个库,涵盖数据处理、图像处理、网络开发、Web框架、人工智能、科学计算、GUI工具、测试框架、环境管理等多... 目录1、数据处理文本处理特殊文本处理html/XML 解析文件处理配置文件处理文档相关日志管理日期和

Python38个游戏开发库整理汇总

《Python38个游戏开发库整理汇总》文章介绍了多种Python游戏开发库,涵盖2D/3D游戏开发、多人游戏框架及视觉小说引擎,适合不同需求的开发者入门,强调跨平台支持与易用性,并鼓励读者交流反馈以... 目录PyGameCocos2dPySoyPyOgrepygletPanda3DBlenderFife

SpringBoot集成EasyPoi实现Excel模板导出成PDF文件

《SpringBoot集成EasyPoi实现Excel模板导出成PDF文件》在日常工作中,我们经常需要将数据导出成Excel表格或PDF文件,本文将介绍如何在SpringBoot项目中集成EasyPo... 目录前言摘要简介源代码解析应用场景案例优缺点分析类代码方法介绍测试用例小结前言在日常工作中,我们经

Python自动化批量重命名与整理文件系统

《Python自动化批量重命名与整理文件系统》这篇文章主要为大家详细介绍了如何使用Python实现一个强大的文件批量重命名与整理工具,帮助开发者自动化这一繁琐过程,有需要的小伙伴可以了解下... 目录简介环境准备项目功能概述代码详细解析1. 导入必要的库2. 配置参数设置3. 创建日志系统4. 安全文件名处

MySQL 迁移至 Doris 最佳实践方案(最新整理)

《MySQL迁移至Doris最佳实践方案(最新整理)》本文将深入剖析三种经过实践验证的MySQL迁移至Doris的最佳方案,涵盖全量迁移、增量同步、混合迁移以及基于CDC(ChangeData... 目录一、China编程JDBC Catalog 联邦查询方案(适合跨库实时查询)1. 方案概述2. 环境要求3.

SpringSecurity整合redission序列化问题小结(最新整理)

《SpringSecurity整合redission序列化问题小结(最新整理)》文章详解SpringSecurity整合Redisson时的序列化问题,指出需排除官方Jackson依赖,通过自定义反序... 目录1. 前言2. Redission配置2.1 RedissonProperties2.2 Red

MySQL 多列 IN 查询之语法、性能与实战技巧(最新整理)

《MySQL多列IN查询之语法、性能与实战技巧(最新整理)》本文详解MySQL多列IN查询,对比传统OR写法,强调其简洁高效,适合批量匹配复合键,通过联合索引、分批次优化提升性能,兼容多种数据库... 目录一、基础语法:多列 IN 的两种写法1. 直接值列表2. 子查询二、对比传统 OR 的写法三、性能分析

Javaee多线程之进程和线程之间的区别和联系(最新整理)

《Javaee多线程之进程和线程之间的区别和联系(最新整理)》进程是资源分配单位,线程是调度执行单位,共享资源更高效,创建线程五种方式:继承Thread、Runnable接口、匿名类、lambda,r... 目录进程和线程进程线程进程和线程的区别创建线程的五种写法继承Thread,重写run实现Runnab