corethink功能模塊探索開發(四)讓這個模塊跑起來
阿新 • • 發佈:2017-12-22
src 後臺菜單 evel pst 新建 mod depend htm news
讓這個模塊跑起來,太費勁了,多半原因是自己太粗心,opencmf.php中“uid”寫成了“pid”,de了好幾天的bug也沒有搞出來,又加上最近發生了些事(brokenhearted)。。。
上報錯圖:
顯示147行錯誤。而且打開那個頁面apache占用率能到了100%+
上正事,讓這個模塊跑起來:
1.編輯Equip/opencmf.php給後臺列表添加url
<?php // 模塊信息配置 return array( // 模塊信息 ‘info‘ => array( ‘name‘ => ‘Equip‘, ‘title‘ => ‘設備‘, ‘icon‘ => ‘fa fa-newspaper-o‘, ‘icon_color‘ => ‘#9933FF‘, ‘description‘ => ‘BZU網絡設備模塊‘, ‘developer‘ => ‘pangPython‘, ‘website‘ => ‘http://www.bzu.edu.cn‘, ‘version‘ => ‘1.0.0‘, ‘dependences‘ => array( ‘Admin‘ => ‘1.1.0‘, ), ), // 用戶中心導航 ‘user_nav‘ => array( ), // 模塊配置 ‘config‘ => array( ‘show_equip‘ => array( ‘title‘ => ‘前臺設備總體情況‘, ‘type‘ => ‘radio‘, ‘options‘ => array( ‘1‘ => ‘顯示‘, ‘0‘ => ‘關閉‘, ), ‘value‘ => ‘1‘, ), ‘show_repaire‘ => array( ‘title‘ => ‘是否開啟前臺報修‘, ‘type‘ => ‘radio‘, ‘options‘ => array( ‘1‘ => ‘開啟‘, ‘0‘ => ‘關閉‘, ), ‘value‘ => ‘1‘, ), ‘show_repaire_phone_num‘ => array( ‘title‘ => ‘報修手機號‘, ‘type‘ =>‘textarea‘, ‘value‘ => ‘‘, ), ), // 後臺菜單及權限節點配置 ‘admin_menu‘ => array( ‘1‘ => array( ‘id‘ => ‘1‘, ‘pid‘ => ‘0‘, ‘title‘ => ‘設備‘, ‘icon‘ => ‘fa fa-newspaper-o‘, ), ‘2‘ => array( ‘pid‘ => ‘1‘, ‘title‘ => ‘操作列表‘, ‘icon‘ => ‘fa fa-folder-open-o‘, ), ‘3‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘模塊配置‘, ‘icon‘ => ‘fa fa-wrench‘, ‘url‘ => ‘Equip/Test/index‘, ), ‘4‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘設備管理‘, ‘icon‘ => ‘fa fa-dashboard‘, ‘url‘ => ‘Equip/DeviceManage/index‘, ), ‘5‘ => array( ‘pid‘ => ‘4‘, ‘title‘ => ‘add‘, ‘url‘ => ‘Equip/DeviceManage/add‘, ), ‘6‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘設備類型‘, ‘icon‘ => ‘fa fa-th-large‘, ‘url‘ => ‘Equip/DeviceManage/index‘, ), ‘7‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘設備報修‘, ‘icon‘ => ‘fa fa-user‘, ), ‘8‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘設備概況‘, ‘icon‘ => ‘fa fa-area-chart‘, ), ‘9‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘拓展‘, ‘icon‘ => ‘fa fa-cogs‘, ), ‘10‘ => array( ‘pid‘ => ‘2‘, ‘title‘ => ‘關於模塊‘, ‘icon‘ => ‘fa fa-commenting-o‘, ), ), );
2.建立頁面的控制器
新建DeviceManageAdmin.class.php
Equip/Admin/DeviceManageAdmin.class.php
<?php /** * Created by PhpStorm. * User: root * Date: 16-3-23 * Time: 下午10:10 */ namespace Equip\Admin; use Admin\Controller\AdminController; use Common\Util\Think\Page; class DeviceManageAdmin extends AdminController { public function index(){ //使用Builder快速建立列表頁面 $builder = new \Common\Builder\ListBuilder(); $builder->setMetaTitle(‘設備管理‘) //設置頁面標題 ->addTableColumn(‘id‘, ‘ID‘) ->addTableColumn(‘create_time‘, ‘設備名稱‘, ‘time‘) ->addTableColumn(‘sort‘, ‘排序‘, ‘text‘) ->addTableColumn(‘status‘, ‘狀態‘, ‘status‘) ->addTableColumn(‘right_button‘, ‘操作‘, ‘btn‘) ->setExtraHtml(‘<div class="alert alert-success">請點擊左側的列表樹進行操作</div>‘) ->display(); } public function add(){ } }
效果圖:
完成了。
其實思路也不難:在配置文件中添加按鈕的跳轉鏈接,創建控制器,這裏的控制器事opencmf重寫的命名為abcdAdmin.class.php,Model可以不寫,試圖可以使用opencmf的Builder創建。
corethink功能模塊探索開發(四)讓這個模塊跑起來