zoukankan      html  css  js  c++  java
  • PHPCMS V9 简单的二次开发

    更多二次开发技巧,查看phpcms系统帮助 ,前台模板解析后的缓存 cachescaches_templatedefault

    前台控制类index.php,前台标签类*_tag.class.php,前台需要的变量可以在前台控制类,前台标签类配合组合返回

    添加一个新功能模块,他的信息存储用文章模型字段有些不能满足 ,一般采取哪些方法解决?

    1.可以直接在数据库上加字段(后台模型管理--文章模型---字段管理,或数据库中直接加)

    2.自定义新的字段模型(后台模型管理--添加模型)

    3.直接建个新表

    二次开发添加数据库表时用其他的标记,已示区分:

    数据库配置文件位置:caches/configs/database.php

    java代码
    <?php   
     return array (
       'default' => array (
         'hostname' => 'localhost',
         'database' => 'phpcms',
         'username' => 'admin',
         'password' => 'admin',
         'tablepre' => 'v9_',
         'charset' => 'gbk',
         'type' => 'mysql',
         'debug' => true,
         'pconnect' => 0,
         'autoconnect' => 0
       ),
        /* 以下默认不存在 */
       'extended' => array (
         'hostname' => 'localhost',
         'database' => 'phpcms',
         'username' => 'admin',
         'password' => 'admin',
         'tablepre' => 'ext_',
         'charset' => 'gbk',
         'type' => 'mysql',
         'debug' => true,
         'pconnect' => 0,
         'autoconnect' => 0
       ),
     );
     ?>
     

    url访问

    http : //yourdomain.com/index.php?m=content&c=index&a=show&id=1

    m = content 为模型/模块名称 位于phpcms/modules/content
    c = index  为控制器名称 位于phpcms/modules/content/index.php
    a = show 为时间名称 位于phpcms/modules/content/index.php 中show()方法
    id = 1 为其他参数 与正常get传递参数形式相同

    phpcms默认路由会定位到content模块的index控制器中的init操作 ,因为系统在没有指定模块和控制器的时候,会执行默认的模块和操作。

    1.修改默认主页

    修改/caches/configs/route.php文件

    2.创建model

    新建一个model phpcms/model/格式:my_model.class.php my指表名,其基本格式如下:

    java代码
    <?php
    defined('in_phpcms') or exit('no permission resources.');
    pc_base::load_sys_class('model', '', 0);
    class my_model extends model {
        public function __construct()
        {
            $this->db_config = pc_base::load_config('database');
            $this->db_setting = 'default';
            $this->table_name = 'my';
            parent::__construct();
        }
    }
    ?>

    3.创建modules

    新建一个my目录 其目录下的目录有 classes functions templates -------这里的目录是后台modules,创建一个前台php文件 mytest.php 其基本内容如下:

    java代码
    <?php
    defined('in_phpcms') or exit('no permission resources.');
    class mytest {
        function __construct()
        {
            $this->db = pc_base::load_model('my_model');
        }
        public function init() {
            $result = $this->db->select();
            var_dump($result);
            include template('my', 'my',$result); //my是templates目录,第二个my是文件名,$result为风格名称,默认不填为defalut
        }
        public function mylist()
        {
            $var = 'hello world!this is a example!';
            echo $var;
      $siteid = get_siteid();
      $seo = seo($siteid, '', $var);
      include $this->admin_tpl("mytest_admin_list");
        }
    }
    ?>

     4.创建templates

    后台templates在phpcmsmodulesmytest emplates

    前台在phpcms emplates

    新建一个my目录 my就是include template('my','my',$style);

    java代码
    {template "content","header"}   

    {template "content","header"}

    {loop $result $value}
        用户id:{$value['id']}<p>
        密码:{$value['username']}<p>
    {/loop}

    {template "content","footer"}

  • 相关阅读:
    【转】VS2010中 C++创建DLL图解
    [转]error: 'retainCount' is unavailable: not available in automatic reference counting mode
    [转]关于NSAutoreleasePool' is unavailable: not available in automatic reference counting mode的解决方法
    【转】 Tomcat v7.0 Server at localhost was unable to start within 45
    【转】Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If
    【转】SVN管理多个项目版本库
    【转】eclipse安装SVN插件的两种方法
    【转】MYSQL启用日志,和查看日志
    【转】Repository has not been enabled to accept revision propchanges
    【转】SVN库的迁移
  • 原文地址:https://www.cnblogs.com/semcoding/p/3358732.html
Copyright © 2011-2022 走看看