PHPCMS后台框架实现思路【原创】

时间 2014-11-27 10:12:19 极客头条 原文  http://blogs.zmit.cn/3589.html

1.打开后台入口文件admin.php

header('location:index.php?m=admin');

跳转到index.php并且m=admin

2.打开index.php

define('PHPCMS_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);

include PHPCMS_PATH.'/phpcms/base.php';

pc_base::creat_app();

定义了根目录,包含了框架的入口文件base.php,并且使用类静态方法creat_app()

3.打开框架入口文件base.php

define('IN_PHPCMS', true);

//PHPCMS框架路径

define('PC_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);

if(!defined('PHPCMS_PATH')) define('PHPCMS_PATH', PC_PATH.'..'.DIRECTORY_SEPARATOR);

//缓存文件夹地址

define('CACHE_PATH', PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR);

//主机协议

define('SITE_PROTOCOL', isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://');

//当前访问的主机名

define('SITE_URL', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));

//来源

define('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');

//系统开始时间

define('SYS_START_TIME', microtime());

//加载公用函数库

pc_base::load_sys_func('global');

pc_base::load_sys_func('extention');

pc_base::auto_load_func();

pc_base::load_config('system','errorlog') ? set_error_handler('my_error_handler') : error_reporting(E_ERROR | E_WARNING | E_PARSE);

//设置本地时差

function_exists('date_default_timezone_set') && date_default_timezone_set(pc_base::load_config('system','timezone'));

define('CHARSET' ,pc_base::load_config('system','charset'));

//输出页面字符集

header('Content-type: text/html; charset='.CHARSET);

define('SYS_TIME', time());

//定义网站根路径

define('WEB_PATH',pc_base::load_config('system','web_path'));

//js 路径

define('JS_PATH',pc_base::load_config('system','js_path'));

//css 路径

define('CSS_PATH',pc_base::load_config('system','css_path'));

//img 路径

define('IMG_PATH',pc_base::load_config('system','img_path'));

//动态程序路径

define('APP_PATH',pc_base::load_config('system','app_path'));

//应用静态文件路径

define('PLUGIN_STATICS_PATH',WEB_PATH.'statics/plugin/');

if(pc_base::load_config('system','gzip') && function_exists('ob_gzhandler')) {

ob_start('ob_gzhandler');

} else {

ob_start();

}

class pc_base {

  /**

* 初始化应用程序

   */

public static function creat_app() {

return self::load_sys_class('application');

}

  /**

* 加载系统类方法

* @param string $classname 类名

* @param string $path 扩展地址

* @param intger $initialize 是否初始化

   */

public static function load_sys_class($classname, $path = '', $initialize = 1) {

return self::_load_class($classname, $path, $initialize);

}

  /**

* 加载应用类方法

* @param string $classname 类名

* @param string $m 模块

* @param intger $initialize 是否初始化

   */

public static function load_app_class($classname, $m = '', $initialize = 1) {

$m = empty($m) && defined('ROUTE_M') ? ROUTE_M : $m;

if (empty($m)) return false;

return self::_load_class($classname, 'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.'classes', $initialize);

}

  /**

* 加载数据模型

* @param string $classname 类名

   */

public static function load_model($classname) {

return self::_load_class($classname,'model');

}

  /**

* 加载类文件函数

* @param string $classname 类名

* @param string $path 扩展地址

* @param intger $initialize 是否初始化

   */

private static function _load_class($classname, $path = '', $initialize = 1) {

static $classes = array();

if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'classes';

$key = md5($path.$classname);

if (isset($classes[$key])) {

if (!empty($classes[$key])) {

return $classes[$key];

} else {

return true;

}

}

if (file_exists(PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) {

include PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php';

$name = $classname;

if ($my_path = self::my_path(PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php')) {

include $my_path;

$name = 'MY_'.$classname;

}

if ($initialize) {

$classes[$key] = new $name;

} else {

$classes[$key] = true;

}

return $classes[$key];

} else {

return false;

}

}

  /**

* 加载系统的函数库

* @param string $func 函数库名

   */

public static function load_sys_func($func) {

return self::_load_func($func);

}

  /**

* 自动加载autoload目录下函数库

* @param string $func 函数库名

   */

public static function auto_load_func($path='') {

return self::_auto_load_func($path);

}

  /**

* 加载应用函数库

* @param string $func 函数库名

* @param string $m 模型名

   */

public static function load_app_func($func, $m = '') {

$m = empty($m) && defined('ROUTE_M') ? ROUTE_M : $m;

if (empty($m)) return false;

return self::_load_func($func, 'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.'functions');

}

  /**

* 加载插件类库

   */

public static function load_plugin_class($classname, $identification = '' ,$initialize = 1) {

$identification = empty($identification) && defined('PLUGIN_ID') ? PLUGIN_ID : $identification;

if (empty($identification)) return false;

return pc_base::load_sys_class($classname, 'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'classes', $initialize);

}

  /**

* 加载插件函数库

* @param string $func 函数文件名称

* @param string $identification 插件标识

   */

public static function load_plugin_func($func,$identification) {

static $funcs = array();

$identification = empty($identification) && defined('PLUGIN_ID') ? PLUGIN_ID : $identification;

if (empty($identification)) return false;

$path = 'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.$func.'.func.php';

$key = md5($path);

if (isset($funcs[$key])) return true;

if (file_exists(PC_PATH.$path)) {

include PC_PATH.$path;

} else {

$funcs[$key] = false;

return false;

}

$funcs[$key] = true;

return true;

}

  /**

* 加载插件数据模型

* @param string $classname 类名

   */

public static function load_plugin_model($classname,$identification) {

$identification = empty($identification) && defined('PLUGIN_ID') ? PLUGIN_ID : $identification;

$path = 'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'model';

return self::_load_class($classname,$path);

}

  /**

* 加载函数库

* @param string $func 函数库名

* @param string $path 地址

   */

private static function _load_func($func, $path = '') {

static $funcs = array();

if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'functions';//默认函数地址在lib function

$path .= DIRECTORY_SEPARATOR.$func.'.func.php';

$key = md5($path);

if (isset($funcs[$key])) return true;

if (file_exists(PC_PATH.$path)) {

include PC_PATH.$path;

} else {

$funcs[$key] = false;

return false;

}

$funcs[$key] = true;

return true;

}

  /**

* 加载函数库

* @param string $func 函数库名

* @param string $path 地址

   */

private static function _auto_load_func($path = '') {

if (empty($path)) $path = 'libs'.DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.'autoload';

$path .= DIRECTORY_SEPARATOR.'*.func.php';

$auto_funcs = glob(PC_PATH.DIRECTORY_SEPARATOR.$path);

if(!empty($auto_funcs) && is_array($auto_funcs)) {

foreach($auto_funcs as $func_path) {

include $func_path;

}

}

}

  /**

* 是否有自己的扩展文件

* @param string $filepath 路径

   */

public static function my_path($filepath) {

$path = pathinfo($filepath);

if (file_exists($path['dirname'].DIRECTORY_SEPARATOR.'MY_'.$path['basename'])) {

return $path['dirname'].DIRECTORY_SEPARATOR.'MY_'.$path['basename'];

} else {

return false;

}

}

  /**

* 加载配置文件

* @param string $file 配置文件

* @param string $key  要获取的配置荐

* @param string $default  默认配置。当获取配置项目失败时该值发生作用。

* @param boolean $reload 强制重新加载。

   */

public static function load_config($file, $key = '', $default = '', $reload = false) {

static $configs = array();

if (!$reload && isset($configs[$file])) {

if (empty($key)) {

return $configs[$file];

} elseif (isset($configs[$file][$key])) {

return $configs[$file][$key];

} else {

return $default;

}

}

$path = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$file.'.php';

if (file_exists($path)) {

$configs[$file] = include $path;

}

if (empty($key)) {

return $configs[$file];

} elseif (isset($configs[$file][$key])) {

return $configs[$file][$key];

} else {

return $default;

}

}

}

①定义各后期可能用到的常量

②创建了pc_base类,加载类并且实例化和

③加载基本框架需要的函数库

④定义creat_app() 包含application且实例化

4.打开框架类库文件下的application.class.php文件

执行构造函数

加载param路由类,使用路由类中的$param->route_m(),$param->route_c(),$param->route_a()获取模块和控制器以及方法,route_m为模块,在modules文件下,然后是控制器和方法,标准的mvc结构

然后执行int函数

执行load_controller加载获取到的控制器并且实例化!

5.打开index.php?m=admin&a=index&c=login登录页面

defined('IN_PHPCMS') or exit('No permission resources.');

pc_base::load_app_class('admin','admin',0);

判断是否从框架入口文件进入,然后加载admin模块下的admin类文件

class index extends admin {

public function __construct() {

parent::__construct(); //调用父类构造方法

$this->db = pc_base::load_model('admin_model');

$this->menu_db = pc_base::load_model('menu_model');

$this->panel_db = pc_base::load_model('admin_panel_model');

}

然后使用构造方法加载使用到的模型文件(MVC中的M),然后看父类的构造方法

6.打开框架类文件admin.class.php

这个类文件,这个模块中的最高级类,做了很多判断操作,以及本模块一些必须的东西(加载模板)

7.然后让我们看admin_model.class.php类

defined('IN_PHPCMS') or exit('No permission resources.');

pc_base::load_sys_class('model', '', 0);

class admin_model extends model {

public function __construct() {

$this->db_config = pc_base::load_config('database');

$this->db_setting = 'default';

$this->table_name = 'admin';

parent::__construct();

}

}

admin_model extends model继承model然后使用了一些方法

<?php

/**

*  model.class.php 数据模型基类

*

* @copyright                            (C) 2005-2010 PHPCMS

* @license                                        http://www.phpcms.cn/license/

* @lastmodify                           2010-6-7

*/

defined('IN_PHPCMS') or exit('Access Denied');

pc_base::load_sys_class('db_factory', '', 0);

class model {

//数据库配置

protected $db_config = '';

//数据库连接

protected $db = '';

//调用数据库的配置项

protected $db_setting = 'default';

//数据表名

protected $table_name = '';

//表前缀

public  $db_tablepre = '';

public function __construct() {

if (!isset($this->db_config[$this->db_setting])) {

$this->db_setting = 'default';

}

$this->table_name = $this->db_config[$this->db_setting]['tablepre'].$this->table_name;

$this->db_tablepre = $this->db_config[$this->db_setting]['tablepre'];

$this->db = db_factory::get_instance($this->db_config)->get_database($this->db_setting);

}

/**

* 执行sql查询

* @param $where             查询条件[例`name`='$name']

* @param $data              需要查询的字段值[例`name`,`gender`,`birthday`]

* @param $limit             返回结果范围[例:10或10,10 默认为空]

* @param $order             排序方式  [默认按数据库默认方式排序]

* @param $group             分组方式  [默认为空]

* @param $key          返回数组按键名排序

* @return array             查询结果集数组

*/

final public function select($where = '', $data = '*', $limit = '', $order = '', $group = '', $key='') {

if (is_array($where)) $where = $this->sqls($where);

return $this->db->select($data, $this->table_name, $where, $limit, $order, $group, $key);

}

/**

* 查询多条数据并分页

* @param $where

* @param $order

* @param $page

* @param $pagesize

* @return unknown_type

*/

final public function listinfo($where = '', $order = '', $page = 1, $pagesize = 20, $key='', $setpages = 10,$urlrule = '',$array = array(), $data = '*') {

$where = to_sqls($where);

$this->number = $this->count($where);

$page = max(intval($page), 1);

$offset = $pagesize*($page-1);

$this->pages = pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);

$array = array();

if ($this->number > 0) {

return $this->select($where, $data, "$offset, $pagesize", $order, '', $key);

} else {

return array();

}

}

/**

* 获取单条记录查询

* @param $where             查询条件

* @param $data              需要查询的字段值[例`name`,`gender`,`birthday`]

* @param $order             排序方式  [默认按数据库默认方式排序]

* @param $group             分组方式  [默认为空]

* @return array/null        数据查询结果集,如果不存在,则返回空

*/

final public function get_one($where = '', $data = '*', $order = '', $group = '') {

if (is_array($where)) $where = $this->sqls($where);

return $this->db->get_one($data, $this->table_name, $where, $order, $group);

}

/**

* 直接执行sql查询

* @param $sql                                                                  查询sql语句

* @return        boolean/query resource                   如果为查询语句,返回资源句柄,否则返回true/false

*/

final public function query($sql) {

$sql = str_replace('phpcms_', $this->db_tablepre, $sql);

return $this->db->query($sql);

}

/**

* 执行添加记录操作

* @param $data              要增加的数据,参数为数组。数组key为字段值,数组值为数据取值

* @param $return_insert_id 是否返回新建ID号

* @param $replace 是否采用 replace into的方式添加数据

* @return boolean

*/

final public function insert($data, $return_insert_id = false, $replace = false) {

return $this->db->insert($data, $this->table_name, $return_insert_id, $replace);

}

/**

* 获取最后一次添加记录的主键号

* @return int

*/

final public function insert_id() {

return $this->db->insert_id();

}

/**

* 执行更新记录操作

* @param $data              要更新的数据内容,参数可以为数组也可以为字符串,建议数组。

*                                                         为数组时数组key为字段值,数组值为数据取值

*                                                         为字符串时[例:`name`='phpcms',`hits`=`hits`+1]。

*                                                         为数组时[例: array('name'=>'phpcms','password'=>'123456')]

*                                                         数组的另一种使用array('name'=>'+=1', 'base'=>'-=1');程序会自动解析为`name` = `name` + 1, `base` = `base` - 1

* @param $where             更新数据时的条件,可为数组或字符串

* @return boolean

*/

final public function update($data, $where = '') {

if (is_array($where)) $where = $this->sqls($where);

return $this->db->update($data, $this->table_name, $where);

}

/**

* 执行删除记录操作

* @param $where             删除数据条件,不充许为空。

* @return boolean

*/

final public function delete($where) {

if (is_array($where)) $where = $this->sqls($where);

return $this->db->delete($this->table_name, $where);

}

/**

* 计算记录数

* @param string/array $where 查询条件

*/

final public function count($where = '') {

$r = $this->get_one($where, "COUNT(*) AS num");

return $r['num'];

}

/**

* 将数组转换为SQL语句

* @param array $where 要生成的数组

* @param string $font 连接串。

*/

final public function sqls($where, $font = ' AND ') {

if (is_array($where)) {

$sql = '';

foreach ($where as $key=>$val) {

$sql .= $sql ? " $font `$key` = '$val' " : " `$key` = '$val'";

}

return $sql;

} else {

return $where;

}

}

/**

* 获取最后数据库操作影响到的条数

* @return int

*/

final public function affected_rows() {

return $this->db->affected_rows();

}

/**

* 获取数据表主键

* @return array

*/

final public function get_primary() {

return $this->db->get_primary($this->table_name);

}

/**

* 获取表字段

* @param string $table_name    表名

* @return array

*/

final public function get_fields($table_name = '') {

if (empty($table_name)) {

$table_name = $this->table_name;

} else {

$table_name = $this->db_tablepre.$table_name;

}

return $this->db->get_fields($table_name);

}

/**

* 检查表是否存在

* @param $table 表名

* @return boolean

*/

final public function table_exists($table){

return $this->db->table_exists($this->db_tablepre.$table);

}

/**

* 检查字段是否存在

* @param $field 字段名

* @return boolean

*/

public function field_exists($field) {

$fields = $this->db->get_fields($this->table_name);

return array_key_exists($field, $fields);

}

final public function list_tables() {

return $this->db->list_tables();

}

/**

* 返回数据结果集

* @param $query (mysql_query返回值)

* @return array

*/

final public function fetch_array() {

$data = array();

while($r = $this->db->fetch_next()) {

$data[] = $r;

}

return $data;

}

/**

* 返回数据库版本号

*/

final public function version() {

return $this->db->version();

}

}

包含了数据库操作封装,然后数据库的连接,大致思路就是如此

phpcms v9框架的目录结构分析

(2013-09-03 10:24:25)

转载▼

   

phpcms v9框架的目录结构分析:  
  
了解v9框架的目录结构,有助于帮助我们快速建立起对v9框架的一个整体认识  
  
打开"mycms"项目,有如下文件和目录  
  
使用协议说明文档、英文版的用户手册,这两项不是项目所必须的,可暂时将其删除  
  
|-----api  接口文件目录  
|-----caches 缓存文件目录  
    |-----configs 系统配置文件目录  
        |-----database.php  数据库配置文件  
        |-----route.php     路由配置文件  
        |-----system.php    系统配置文件  
        |-----cache.php     缓存配置文件  
    |-----configs_*         系统缓存文件目录  
        |-----configs_commons/caches_data   主要用来存放后台设置的配置信息  
            |-----category_content.cache.php栏目与站点映射所对应的配置文件  
            |-----category_content_1.cache.php站点1下所有栏目的详细配置信息  
            |-----category_item_1.cache.php 文章模型下各栏目所对应的数据量  
            |-----category_item_2.cache.php 下载模型下各栏目所对应的数据量  
            |-----category_item_3.cache.php 图片模型下各栏目所对应的数据量  
            |-----keylink.cache.php     关联链接配置缓存文件  
            |-----model.cache.php       三大模型配置缓存文件  
            |-----mood_program.cache.php    表情配置缓存文件  
            |-----position.cache.php    推荐位配置缓存文件  
            |-----poster_template_1.cache.php广告位模板配置缓存文件  
            |-----sitelist.cache.php    站点列表配置文件,主要缓存所有站点的基本配置信息  
            |-----type_content.cache.php    多个站点下的类别配置信息  
            |-----type_content_1.cache.php  当前站点下类别配置信息缓存文件  
            |-----urlrules.cache.php    url规则配置信息缓存文件  
            |-----urlrules_detail.cache.php url规则详细配置信息缓存文件  
            |-----special.cache.php     专题配置信息缓存文件  
            |-----role.cache.php        角色配置缓存文件  
            |-----link.cache.php        友情链接缓存文件  
        |-----configs_model/caches_data  
            |-----content_form.class.php    生成表单的类库缓存文件  
            |-----content_input.class.php   入库时,对表单数据进行验证的类库缓存文件  
            |-----content_output.class.php  对从数据表中查询出来的数据进行处理的函数  
            |-----content_update.class.php  对要更新的数据进行有效性验证的函数  
            |-----model_field_1.cache.php   文章模型所有模型字段的缓存信息  
            |-----model_field_2.cache.php   下载模型所有模型字段的缓存信息  
            |-----model_field_3.cache.php   图片模型所有模型字段的缓存信息  
  
              
|-----phpcms                        phpcms框架主目录  
       |-----languages                  框架语言包目录  
       |-----libs                   框架主类库、主函数库目录  
        |-----classes  
            |-----form.class.php    表单生成类库文件  
            |-----application.class.php 应用程序类库文件  
            |-----image.class.php       图片处理类库文件  
            |-----attachment.class.php  附件处理类库文件  
            |-----param.class.php       URL参数处理类库文件  
        |-----functions  
            |-----global.func.php       公共函数库文件  
            |-----extension.class.php   扩展函数库文件  
       |-----model                  框架数据库模型目录  
        |-----content_model.class.php       内容模型文件  
        |-----admin_model.class.php     管理员模型文件  
        |-----attachment_model.class.php    附件模型文件  
       |-----modules                    框架模块目录  
        |-----admin             admin模块   
            |-----index.php         index.php控制器文件  
        |-----content               content模块  
            |-----classes           content模块通用类库  
            |-----fields            content模块模型字段  
            |-----functions         content模块通用函数库  
            |-----templates         content模块后台模板文件  
            |-----index.php         index.php控制器文件  
       |-----templates                  框架系统前台模板目录  
        |-----default               默认的模板风格  
            |-----content           content模块模板目录  
                |-----category.html 频道页模板文件  
                |-----list.html     列表页模板文件  
                |-----show.html     内容页模板文件  
            |-----config.php        模板配置文件  
|-----phpsso_server                 phpsso主目录  
|-----statics                       网站素材文件目录  
    |-----css                                   css文件  
        |-----images                    images文件  
        |-----js                    js文件  
|-----uploadfile                    上传附件  
|-----admin.php                     后台入口文件  
|-----index.php                     前台入口文件  
  
  
  
  
phpcms v9中的url路由规则:  
  
  
浏览器中输入 http://www.mycms.com/index.php?m ... ;a=list&catid=1  回车时,默认情况下会找到  
phpcms                  框架主目录  
|-----modules               模块目录  
    |-----content           content模块  
        |-----index.php     index.php控制器中list方法来显示列表页面  
              
  
到底是不是呢?我们打开index.php控制器文件,并在index方法中添加一些代码,运行输出,证明确实如我们所料  
  
我们可以将浏览器中的url归纳如下:  
http://域名/入口文件?m=模块名&c=控制器&a=方法名&catid=参数值  
  
  
当我们在浏览器中输入http://www.myshop.com/index.php 后面没有跟任何参数, 回车时,默认情下会将首页显示出来  
  
这是因为phpcms v9为我们指定了一个默认执行的模块、控制器和方法  
  
默认控制器的设置在 "caches/configs/routes.php" 配置文件中进行设置的,我们可以重新设置默认的控制器  
  
六、栏目的添加  
  
1、pc设计者认为,栏目详情页的数据都应该属于一个模型,所以在添加栏目时,必须给栏目指定一个模型,至于要选择什么模型,完全取决于栏目详情页要显示什么类型的内容  
   详情页:文章信息类的内容     文章模型  
   详情页:图片类信息            图片模型  
   详情页:下载东西         下载模型  
   详情页:播放视频         视频模型  
  
2、如果以上模型还不能满足项目的需要,那么我们还可以自定义模型,通常情况下,一个网站是由多种模型的数据来组成的  
  
3、栏目添加选项:  
  
栏目名称:在网站静态化时,创建一个以此目录名命名的目录来存放当前栏目下相关的模板文件  
  
4、pc的设计者认为,每个栏目会对应当前所选模型的三个模板文件:  
  
频道页模板文件  
  
列表页模板文件  
  
内容页模板文件  
  
  
这些模板文件所在位置:phpcms/templates/default/content/ 目录下,如果想修改模板文件,只需要到此目录下找到对应的模板文件进行修改就可以了  
  
频道页:category_*.html  
列表页:list_*.html  
内容页:show_*.html  
  
至此,栏目各页面与模型的三个模板文件对应起来了  
  
注意:频道页面的显示是有条件的(当前栏目必须有子栏目才可以)  
  
  
5、栏目添加成功后,栏目信息被存储到了v9_category数据表中,同时还被缓存到了phpcms/caches/caches_common/category_content.cache.php文件中,这个缓存文件非常重要,一定要引起足够的重视,前台的很多数据都是直接从此缓存文件中获取来的  
  
  
  
七、项目的部署:  
  
1、素材文件:  
  
statics  
    |-----images  
        |-----cmsimages     项目图片文件  
    |-----js  
        |-----cmsjs     项目js文件  
    |-----css  
        |-----cmscss        项目css文件  
  
phpcms  
    |-----templates  
        |-----new       新的模板风格  
            |-----content   内容模块模板文件  
                |-----category.html 频道页模板文件  
                |-----list.html     列表页模板文件  
                |-----show.html     内容页模板文件  
            |-----config.php        添加模板文件的配置  
          
        或者  
  
        |-----default  
            |-----content   内容模块模板文件  
                |-----category_shetu.html   频道页模板文件  
                |-----list_shetu.html       列表页模板文件  
                |-----show_shetu.html       内容页模板文件  
            |-----config.php            配置新添加的模板文件  
  
  
注意:模板文件的命名规范  
  
  
2、进入后台,将栏目与模板文件对应起来  
  
3、常量的定义:phpcms/base.php文件  
  
4、系统类库、函数库、模型文件及配置文件的加载  
  
pc_base::load_sys_class();//加载系统类库  
pc_base::load_sys_func();//加载系统函数库  
pc_base::load_model();//加载模型  
pc_base::load_config();//加载配置文件或配置选项信息  
pc_base::load_app_func();//加载应用程序函数库  
pc_base::load_app_class();//加载应用程序类库  
  
全局范围可用,也可以直接在模板文件中使用,在二次开发时,很有用  
  
5、模板语法:  
  
(1)常量表示:  
  
{JS_PATH}//相当于 或者

s

转载于:https://www.cnblogs.com/Republic/p/4783705.html

PHPCMS后台框架实现思路相关推荐

  1. 基于.Net 写我自己的Ajax后台框架AjaxFramework

    小小目录: 为什么要写自己的Ajax后台框架 框架的简单设计说明 框架如何使用 框架使用效果图 框架的优缺点 框架源码下载 1.为什么要写自己的Ajax后台框架 现在Ajax在web应用方面已经用的稀 ...

  2. 房间类游戏后台框架(一)—介绍

    闲来无事用GO语言写了个简易的房间类游戏后台框架,目前实现基本房间功能,并放了贪吃蛇游戏进去,可实现多人在线贪吃蛇.由于没有前端,导致项目难以继续下去.整个项目大概完成75%,基本目标也都实现,看以后 ...

  3. JQuery Smart UI 简介(六) — 框架设计【后篇】(数据接口、后台框架)[简介系列完结]...

    上篇介绍了Smart UI的前台架构,本篇继续后面的内容 - Data Interface.Business Layout.DataAccess. Data Interface 数据接口,Smart ...

  4. python:web后台框架简单实现

    python:web后台框架 目录 简介:BS开发和http协议 WSGI概述 类flask框架简单实现 response使用及wsgify装饰器 路由 模板原理 jinjia2模板技术 模块化,ja ...

  5. Spring3.2.0-mybatis3.2.0 基于全注解搭建的后台框架-基础版

    2019独角兽企业重金招聘Python工程师标准>>> 摘要: Spring3.2.0-mybatis3.2.0 基于全注解搭建的后台框架-基础版 没有什么不可能  之前一直用的是自 ...

  6. 对接接口文档_接口自动化测试框架设计思路

    接口自动化测试--框架设计思路 1 前言 之前文章跟大家分享了一下自己在接口自动化测试中进行测试准备的一些相关知识点,接下来本篇文章详细分享一下接口自动化框架设计的思路总结,希望能对初次探索接口自动化 ...

  7. 基于ASP.Net Core开发的一套通用后台框架

    基于ASP.Net Core开发一套通用后台框架 写在前面 这是本人在学习的过程中搭建学习的框架,如果对你有所帮助那再好不过.如果您有发现错误,请告知我,我会第一时间修改. 知其然,知其所以然,并非重 ...

  8. 插件框架实现思路及原理

    插件框架实现思路及原理 一.技术可行性 a) apk的安装处理流程 i. apk会copy到/data/app: ii. 解压apk中的class.dex,并对其进行优化,获得odex(即JIT).最 ...

  9. Android 插件框架实现思路及原理

    插件框架实现思路及原理 一.技术可行性 a) apk的安装处理流程 i. apk会copy到/data/app: ii. 解压apk中的class.dex,并对其进行优化,获得odex(即JIT).最 ...

最新文章

  1. 堪比Focal Loss!解决目标检测中样本不平衡的无采样方法
  2. 3分钟销量破千 这款笔记本告诉你大家喜欢的轻薄本什么样!
  3. https HttpsURLConnection请求的单向认证
  4. 【知识导图】数据结构与算法
  5. Apache RocketMQ在我司的最佳实践--智慧政务场景下的分布式消息与分布式事务
  6. 单机按钮来图片轮播_原生js如何实现轮播图效果?
  7. 曼联球星普巴来罗!POGMOJI APP即将上市
  8. 微信公众号数据分析报告
  9. Cadence allegro PCB快速自动创建差分对
  10. sharding异常之no table route info
  11. 【VUE】【VUE-CLI】【bootstrap】【jeecgboot】干部任免表前端
  12. linux 系统时间 硬件时间 及 时区设置
  13. 看完后想10秒钟,你会改变自己!
  14. 使用seleinum模块动态爬取熊猫直播平台全部的主播房间。
  15. *寒假水105——Reduced ID Numbers
  16. 读写文件操作OpenFile()
  17. 太牛了,24 个好用到爆的 Python 实用技巧
  18. 积极推动上市银行 进入交易所债市
  19. (01)ORB-SLAM2源码无死角解析-(61) 闭环线程→闭环矫正: CorrectLoop→全代码注释
  20. Paper/CV之IA:《First Order Motion Model for Image Animation图像动画的一阶运动模型》翻译与解读

热门文章

  1. [Nodejs]初探nodejs学习笔记- 如何使用nodejs搭建简单的UDP聊天功能
  2. 循环类里面的每一个属性
  3. TCP/IP 5.3.5 认证
  4. window.parent ,window.top,window.self 详解
  5. mysql8允许外网访问(转载+整理)
  6. flink写入hive的时区问题
  7. 编译Flink项目的时候遇到cannot find symbol   symbol:   variable Time
  8. synaptic不停抖动后自动关闭的问题
  9. kaggle提交前预估本地cv和LB上的score是否相差很大
  10. python绘制神经网络(转载)