Welcome Guest, Not a member yet? Register   Sign In
Extending controller to fetch common data... but not 100% of the time.
#1

[eluser]BilliamTheSecond[/eluser]
I've extended my controller to handle queries used for things like header navigation.

However, right now I'm running queries on pages that never load a view (ex: self-submitting form pages that redirect on success).

How should I deal with automatically fetching data almost all of the time? I only need to run this query if a view is going to be loaded, and specifically, only if the header is loaded.

Really, my header doesn't need to be dynamic right now, and could just be cached, so this is more of a general question.
#2

[eluser]n0xie[/eluser]
The way I usually do it, is call a render() function at the end of each function. This builds the template (header/footer/menu) based on which class is loaded and injects some data into it. In this case if you have a self submitting form, just don't call the render function. I don't like auto-loading a lot of stuff from the base_controller because it will slow your page down, since it will ALWAYS load them, even if you don't need them.
#3

[eluser]Phil Sturgeon[/eluser]
Different base controllers?




Theme © iAndrew 2016 - Forum software by © MyBB