PHPCMS V9 容易的二次開發

來源:互聯網
上載者:User
PHPCMS V9 簡單的二次開發

更多二次開發技巧,查看phpcms系統協助,前台模板解析後的緩衝 caches\caches_template\default

前台控制類index.php,前台標籤類*_tag.class.php,前台需要的變數可以在前台控制類,前台標籤類配合組合返回

?

添加一個新功能模組,他的資訊儲存用文章模型欄位有些不能滿足,一般採取哪些方法解決?

1.可以直接在資料庫上加欄位(後台模型管理--文章模型---欄位管理,或資料庫中直接加)

2.自訂新的欄位模型(後台模型管理--添加模型)

3.直接建個新表

?

二次開發添加資料庫表時用其他的標記,已示區分:

資料庫設定檔位置:caches/configs/database.php

? 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指表名,其基本格式如下:

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 其基本內容如下:

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在phpcms\modules\mytest\templates

前台在phpcms\templates

建立一個my目錄 my就是include template('my','my',$style);

{template "content","header"}{loop $result $value}    使用者ID:{$value['id']}

密碼:{$value['username']}

{/loop}{template "content","footer"}

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.