Welcome Guest, Not a member yet? Register   Sign In
Variable data in static views
#1

[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 Smile ).

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>
    &lt;?php echo $this->load->view("layout/my_header_view")?&gt;
</div>

<div id=right_column>
    &lt;?php echo $this->load->view("layout/my_right_column_view")?&gt;
</div>

<div id=main>
    &lt;?php echo $this->load->view($may_variate)?&gt;
</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"] = "--&gt;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:


Messages In This Thread
Variable data in static views - by El Forum - 03-23-2010, 11:07 AM
Variable data in static views - by El Forum - 03-23-2010, 11:17 AM
Variable data in static views - by El Forum - 03-23-2010, 11:21 AM
Variable data in static views - by El Forum - 03-23-2010, 11:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB