TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
About class inheritance and vars transfer
  • Dear All,

    I have a question about class controller realization. I have common controller for almost all site pages I call it Controller_Base. In this controller I set menu and breadcrumbs: public $breadcrumbs = array('Главная' => '/'); public $menu= array('Главная' => '/', ‘О фирме’=>’about’, ‘Контакты’=>’contact’, ‘Продукция’=>’production’); In function before() in Controller_Base I have code:

    public function before() {

        parent::before();
    
        $this->template->breadcrumbs = Breadcrumb::render($this->breadcrumbs);
    
        $this->template->menu = $this->menu;
    
    }
    

    But I have also Controller_User, which don't need menu and breadcrumbs in page for user login, registration and etc. .

    If in controller Controller_User I make code:

    class Controller_User extends Controller_Base {

    public function action_login() {
        $data = array();
        $data['error'] = '';
        $data['email'] = '';
        $data['password'] = '';
        $data['remember'] = '';
        unset($this->breadcrumbs);
        unset($this->menu);
        $this->template->content = View::factory('User/Login',$data);
    }
    

    }

    Menu and breadcrumbs stay in screen.

    How I can reset and where vars menu and breadcrumbs?

    I use Kohana 3.3.1.

    With best regards, Alex