+1 vote
1.2k 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 1.7k views
asked Aug 23, 2016 in Kohana by Justin
0 votes
1 answer 1.6k views
asked Aug 23, 2016 in Kohana by James
0 votes
1 answer 1.2k views
0 votes
1 answer 1.6k views
0 votes
1 answer 3.2k views
0 votes
0 answers 3.6k views
...