Welcome Guest, Not a member yet? Register   Sign In
Loading views within a view file
#5

[eluser]sophistry[/eluser]
@Colin Williams... I'd submit that using $this->load->vars() CI loader method is "simpler" than adding a class variable to your controller. And it's shorter. Unless by "simpler" you mean "I prefer it" ;-)

This shows a typical use (used in the constructor) of the vars() method of the Loader class. And, incidentally, it's also the way I prefer to do this sort of thing. Thanks Colin for a nice Template to work from! :-)

Code:
class Blog extends Controller {
      
   function Blog()
   {
      parent::Controller();
      // load entire view output into object scope
      $this->load->vars( array(
         'header' => $this->load->view('header', '', TRUE),
         'footer' => $this->load->view('footer', '', TRUE)
      ));
   }
  
   function index()
   {
      $data['blogs'] = $this->blog_model->get_recent(5);
      $data['content'] = $this->load->view('blog/front', $data, TRUE);
      $this->load->view('template', $data);
   }
  
}


Messages In This Thread
Loading views within a view file - by El Forum - 08-15-2008, 03:22 PM
Loading views within a view file - by El Forum - 08-15-2008, 04:13 PM
Loading views within a view file - by El Forum - 08-15-2008, 05:01 PM
Loading views within a view file - by El Forum - 08-15-2008, 06:23 PM
Loading views within a view file - by El Forum - 08-15-2008, 06:44 PM
Loading views within a view file - by El Forum - 08-19-2008, 12:30 PM
Loading views within a view file - by El Forum - 12-23-2008, 05:07 PM
Loading views within a view file - by El Forum - 12-23-2008, 09:01 PM
Loading views within a view file - by El Forum - 08-21-2009, 09:07 AM
Loading views within a view file - by El Forum - 08-21-2009, 10:00 AM
Loading views within a view file - by El Forum - 02-01-2010, 05:11 PM
Loading views within a view file - by El Forum - 02-01-2010, 07:27 PM
Loading views within a view file - by El Forum - 04-12-2010, 03:55 PM
Loading views within a view file - by El Forum - 04-13-2010, 12:36 AM
Loading views within a view file - by El Forum - 04-13-2010, 01:09 AM
Loading views within a view file - by El Forum - 04-13-2010, 01:12 AM
Loading views within a view file - by El Forum - 04-13-2010, 01:30 AM
Loading views within a view file - by El Forum - 04-13-2010, 01:40 AM
Loading views within a view file - by El Forum - 04-13-2010, 01:47 AM
Loading views within a view file - by El Forum - 04-13-2010, 06:42 AM
Loading views within a view file - by El Forum - 04-13-2010, 07:37 AM
Loading views within a view file - by El Forum - 04-15-2010, 03:21 AM
Loading views within a view file - by El Forum - 01-18-2012, 10:55 PM
Loading views within a view file - by El Forum - 02-08-2012, 07:55 AM
Loading views within a view file - by El Forum - 04-06-2012, 05:05 PM
Loading views within a view file - by El Forum - 04-07-2012, 08:26 PM
Loading views within a view file - by El Forum - 05-02-2012, 07:32 AM
Loading views within a view file - by El Forum - 05-20-2012, 11:31 AM
Loading views within a view file - by El Forum - 07-01-2012, 06:30 AM
Loading views within a view file - by El Forum - 07-01-2012, 07:51 AM
Loading views within a view file - by El Forum - 07-19-2012, 04:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB