zoukankan      html  css  js  c++  java
  • CI 搭建CMS框架

    1. 继承类只能从core或者其他系统内置的目录中继承,不支持随便继承。

    2. 本例子中是从core目录中继承CI_Controller类,而且名字有特殊要求,需要MY_ 开头,并且后面要有继承的类的名字,比如MY_Controller。

    3.在MY_Controoler中,构建父类。代码如下

    class MY_Controller extends CI_Controller{
    
            public function __construct()
            {
                parent::__construct();
    
                 $this->load->model('rbac_model');
                 $this->load->helper('url_helper');
            }
    
    
    
            public function topleft()
            {
            
            $data['rbac'] = $this->rbac_model->get_rbac();
    
    
            $this->load->view('pf_top');
            $this->load->view('pf_left',$data);
        
    
            
            } 
    
            public function right(){
                    $this->load->view('pf_right');
        
            }
    
            public function bottom(){
    
                    $this->load->view('pf_bottom');
            }
    
            public function index(){
    
                $this->topleft();
                $this->right();
                $this->bottom();
            }
        }

    代码的一部分是用了用了后台显示的。

    在具体的子类中,需要重载父类,并且重写right方法,即可实现右侧显示的更换。

     1 Class Pf_first extends MY_Controller {
     2 
     3     
     4         
     5     public function index(){
     6 
     7         parent::index();
     8 
     9     }
    10 
    11     public function right(){
    12         $this->load->view('pf_right');
    13     }
    14 
    15     }

    通过重写right,即可实现右侧代码的更换。

  • 相关阅读:
    ASP.NET MVC IIS7 403.14-Forbidden
    SQL Server 查询锁表和接锁表
    一款不错的golang配置文件库
    某奇艺滑块
    爬虫系列
    Docker部署Python爬虫项目
    Cmder
    Selenium处理alert/confirm/prompt提示框
    Django2.0使用
    排序
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/7159335.html
Copyright © 2011-2022 走看看