[eluser]Unknown[/eluser]
Hello everyone!
I know it sounds kind of contradictory but that's my problem (and maybe i can catch your attention easily
).
I've started using CI a few days and i'm stuck in a view/controller issue. I've made a layout view that contains the main elements of my system, something like this (just as an example):
In my main layout (let's say layout/layout.php):
...
Code:
<div id=header>
<?php echo $this->load->view("layout/my_header_view")?>
</div>
<div id=right_column>
<?php echo $this->load->view("layout/my_right_column_view")?>
</div>
<div id=main>
<?php echo $this->load->view($may_variate)?>
</div>
And let's assume that i have some variables that the view expects from the controller
Code:
my_header_view => $my_header_view_DATA
my_right_column_view=>$my_right_column_view_DATA
And in my controller, for example the "welcome controller"
...
Code:
function index(){
$data["my_header_view_DATA"] = "Tralala"
$data["may_variate"] = "Hello there, i'am the main section!"
$data["my_right_column_view_DATA"] = "-->Something that i'm bringing from my database<--"
$this->load->view('layout/layout', $data);
}
My question is. It's abssolutly necessary to load in every controller the '$data["my_right_column_view_DATA"]' variable?, (What if i have hundreds of controllers? it's not really scalable or maintainable)
Maybe one workaround is to let the "my_right_column_view" have a call to my model and load the data from the database, but i don't think that's a good practice.
Is there something that i'm missing? It's possible to have a "data preload" for the right column view? (maybe a trick with hooks?)
Thanks a lot, i'm kind of disoriented here :down:
Ps. Sorry for my english, i've lost a lot of practice :red: