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

[eluser]wiredesignz[/eluser]
This is the menu plugin (application/plugins/menu_pi.php) acting as a controller.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Menu //plugin acting as psuedo-controller
{
    var $view;
    
    function Menu()
    {
        $this->view  = new View('admin/menu');
    }
    
    function render()    //all partials require a render() method
    {
        $menu = new Menus_model();
        
        extract($this->view->data); // grab the menu setup from the View
        
        $this->view->set(array(     // build the menu parts
            'shop_menu'     => $model->shop_menu(),
            'users_menu'    => $model->users_menu($access_level, $catcode),
            'category_menu' => $model->category_menu($page, $catcode),
        ));
        
        $this->view->render();
    }
}

When the application View Object is told to render() it automatically calls the menu->render() function.


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