+1 vote
345 views
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
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 956 views
asked Aug 23, 2016 in Kohana by Justin
0 votes
1 answer 803 views
asked Aug 23, 2016 in Kohana by James
0 votes
1 answer 636 views
0 votes
1 answer 870 views
0 votes
1 answer 95 views
0 votes
3 answers 1.3k views
...