+1 vote
280 views
asked in Kohana by
The same view (a layout) used for all pages in Kohana3.3 project. That's why it could be placed in before() method instead of every action. Right?

Is there any better way to optimize the code below so you shouldn't use so many $this->? Are there any other improvements of this code so it looks really good?

1 Answer

0 votes
answered by
You need to extend your controller template like this below.

class Controller_Main extends Controller_Template {
   //This it the main html container i suggest use html5boilerplaite
   public function $_template = 'layout'; 

   public function action_index() {
      $data = array();
      $this->template->content = View::factory('frontend/home',$data);
   }
}

class Controller_Profile extends Controller_Main{

   public function action_index() {
      $data = array();
      $this->template->content = View::factory('frontend/profile',$data);
   }
}

Related questions

0 votes
1 answer 886 views
asked Aug 23, 2016 in Kohana by Justin
0 votes
1 answer 712 views
asked Aug 23, 2016 in Kohana by James
0 votes
1 answer 571 views
0 votes
1 answer 804 views
0 votes
1 answer 37 views
...