zoukankan      html  css  js  c++  java
  • PHPCMS后台框架实现思路

    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

  • 相关阅读:
    Delphi程序流程三(2)(while)PS:最简单的任务管理器( 组件LISTVIEW的用法 增加LISTVIEW的读取 删除)
    Delphi 编译错误信息表(转载自万一博客)
    Delphi程序流程三(1)(while)PS:顺便写了个最简单的任务管理器(包含申明API 自己申明参数为结构型API 组件LISTVIEW的用法)
    Delphi程序流程二(for)
    内核编程 warning C4273: 'PsGetProcessId' : inconsistent dll linkage
    简单的SEH处理
    【转】VC6.0各个文件说明
    【转】两篇关于__security_cookie的介绍
    完美解决 error C2220: warning treated as error
    【转】IDA 与VC 加载符号表
  • 原文地址:https://www.cnblogs.com/Republic/p/4783705.html
Copyright © 2011-2022 走看看