Welcome Guest, Not a member yet? Register   Sign In
Using Nested MVC for View partials (Updated)
#4

[eluser]wiredesignz[/eluser]
This is an example of my application admin pages controller (application/controllers/admin/admin_controller.php)
The point to note here is that the menu plugin is loaded and instantiated as a view partial.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Admin_controller extends Controller {

    function Admin_controller($page = 'main', $access_level = 2) //set default access level
    {
        parent::Controller();
        $this->load->model('base_model'); // required by all models
        
        $this->load->model('menus_model');
        $this->load->plugin('menu');
        
        $this->load->library('user', $access_level);
        
        $this->view->set(array(
            'access_level'  => $access_level,
            'catcode'       => -1,        //default no category menu
            'page'          => $page,
        ));
        
        $this->view->load(array(        // setup admin pages partials
            'header'    => 'header',    
            'menu'      =>  new Menu(), // create menu object as partial
            'content'   => 'admin/'.$page,
            'footer'    => 'footer',
        ));
    }
}
Plugin classes are not initialised by CI when loaded. (unlike libraries)


Messages In This Thread
Using Nested MVC for View partials (Updated) - by El Forum - 02-03-2008, 05:56 PM
Using Nested MVC for View partials (Updated) - by El Forum - 02-03-2008, 06:03 PM
Using Nested MVC for View partials (Updated) - by El Forum - 02-03-2008, 06:21 PM
Using Nested MVC for View partials (Updated) - by El Forum - 02-03-2008, 06:26 PM
Using Nested MVC for View partials (Updated) - by El Forum - 02-03-2008, 06:49 PM
Using Nested MVC for View partials (Updated) - by El Forum - 02-04-2008, 01:11 AM
Using Nested MVC for View partials (Updated) - by El Forum - 02-04-2008, 01:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB