Welcome Guest, Not a member yet? Register   Sign In
Can _output function within a controller load views?
#9

[eluser]christian.schorn[/eluser]
Actually I think this is not a bug - if you go through the routes to find the controller, instantiate it (and maybe load a lot of libraries via the controllers constructor) you lose very much of the effectiveness of CIs caching as it is.

In this case it would be enough to make a special method, either in a MY_Controller, or as you need it. Example:
Code:
class MY_Controller extends Controller
{
  var $header_view = 'header';
  var $header_vars = array();

  var $footer_view = 'footer';
  var $footer_vars = array();

  function _pretty_output($view_name, $view_vars = array())
  {
    $this->load->view($this->header_view, $this->header_vars);
    $this->load->view($view_name, $view_vars);
    $this->load->view($this->footer_view, $this->footer_vars);
  }
}
This version limits you to one view per method and you have to call it manually from a controller method, but you get to keep caching. Smile

Then there are hooks ... you could write your own cache_override hook ... but that's a little much just for layout purposes, IMO.

Edit: Or you could do it via a library, as gtech posted, while I was writing this ...


Messages In This Thread
Can _output function within a controller load views? - by El Forum - 05-04-2008, 02:20 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 03:31 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 03:58 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 04:06 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 04:49 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 05:06 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 05:23 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 05:34 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 05:39 PM
Can _output function within a controller load views? - by El Forum - 05-04-2008, 05:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB