+1 vote
236 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 776 views
asked Aug 22, 2016 in Kohana by Justin
0 votes
1 answer 636 views
asked Aug 22, 2016 in Kohana by James
0 votes
1 answer 503 views
0 votes
1 answer 665 views
0 votes
1 answer 25 views
0 votes
0 answers 271 views
...