应用插件模型类必须存在一个基础模型类,命名规则为: models/应用名.php

基本代码如下:

<?php namespace Poscms\Model\Test;

class Test extends \Poscms\Model\App {
   
                                                                                                                                        
    /**
     * 将应用菜单安装至后台菜单中
     *
     * @param   string  $dir    应用目录名称
     * @param   intval  $id     应用id
     * @return  void
     */
    public function install_admin_menu($dir, $id) {
                                                                                                                                            
        $config = require(APPSPATH.$dir.'/config/app.php');
                                                                                                                                            
        // 安装至后台菜单,下面这话的目的是将test控制器加入到后台菜单中
        $this->db->insert('admin_menu', array(
            'pid' => 75,
            'uri' => $dir.'/admin/test/index',
            'mark' => 'app-'.$dir,
            'langname' => dr_name2lang($config['name']),
            'displayorder' => (int)$id+1,
        ));
                                                                                                                                            
    }
                                                                                                                                        
    // 这里可以写其他操作类
}

被继承的A_Model类代码如下:

 
                                                                                                       
    /**
     * 删除模块时调用
     *
     * @param   string  $module 模块目录
     * @param   intval  $siteid 站点id,默认为全部站点
     * @return  string
     */
    public function delete_for_module($module, $siteid = 0) {
                                                                                                       
    }
                                                                                                       
    /**
     * 删除模块内容时调用
     *
     * @param   string  $module 模块目录
     * @param   intval  $siteid 站点id,默认为全部站点
     * @return  string
     */
    public function delete_for_cid($cid, $module) {
                                                                                                       
    }
                                                                                                       
    /**
     * 删除会员时调用
     *
     * @param   intval  $uid    会员uid
     * @return  string
     */
    public function delete_for_uid($uid) {
                                                                                                       
    }
                                                                                                       
    /**
     * 将应用菜单安装至后台菜单中
     *
     * @param   string  $dir    应用目录名称
     * @param   string  $module 模块目录名称
     * @return  void
     */
    public function install_admin_menu($dir, $module = NULL) {
                                                                                                           
    }
                                                                                                       
    /**
     * 将应用菜单安装至会员菜单中
     *
     * @param   string  $dir    应用目录名称
     * @param   string  $module 模块目录名称
     * @return  void
     */
    public function install_member_menu($dir, $module = NULL) {
                                                                                                           
    }

这些方法用于关联调用,如果你的应用有这些东西,你可以在基础模型类中重写它们




文档最后更新时间:2018-12-04 16:17:08