Welcome Guest, Not a member yet? Register   Sign In
How to handle controller for every reload ?
#3

[eluser]Dready[/eluser]
That's a good question. You'll perhaps find utilities that do this for you (advanced templates classes, etc) in the wiki. My personnal trick is to create an helper function that I call at the end of any controller function, and that adds all the stuff. Something like :

Code:
// inside controller function
... processing ...
$main_html = $this->parser->parse('whatever',$tplarray,true);
return render_output($main_html);
}

and an helper like :

Code:
function render_output($main_html) {
  $ci=&get;_instance();
  $tpl = array ('main'=>$main_html);
  $tpl['left_menu'] = $ci->menu->get_html();
  $tpl['other_part'] = other_thing();
  $ci->parser->parse('body',$tpl);
}

That's enough, and you have the choice not to call your helper function, for example in case of a controller method returning an AJAX response in json, or whatever.


Messages In This Thread
How to handle controller for every reload ? - by El Forum - 09-30-2008, 03:22 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 04:14 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 04:29 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 05:18 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 07:18 AM
How to handle controller for every reload ? - by El Forum - 09-30-2008, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB