Welcome Guest, Not a member yet? Register   Sign In
Multiple Views & Dynamic Data
#1

[eluser]Freakish_05[/eluser]
Evening all,

Further to my thread about multiple smarty views with CI, I've ditched smarty is it seemed to make things far more complicated than using CI's views.

I how have a new problem....
My sidebars and navbars are very often run from databases and frequently use URL variables to return data.

What is the best method of doing this in CI? The php code obviously needs to run before CI outputs the final view.
If I understand the MVC approach correctly, I should be creating plugins for all of my sidebar elements and then wrapping them all up in an addtional plugin function which is called in each of my controllers.

All comments greatly appreciated,
Freakish_05
#2

[eluser]Bacteria Man[/eluser]
I assume by "URL variables" you mean segment values (?)

It sounds like you need to devise a method for controlling when/where your sidebar and nav elements appear. There are tons of examples on how to go about this.

Perhaps you can provide a more specific example of what you're trying to do.
#3

[eluser]Michael Wales[/eluser]
I would just load the dynamic data for my sidebar into $data['sidebar'] pass the $data array to the main view (which will hold all your other dynamic data). Then load the sidebar, from the main view, as such:
Code:
$this->load->view('sidebar', $sidebar);
#4

[eluser]Bacteria Man[/eluser]
This simple example illustrates one way to accomplish it.




Theme © iAndrew 2016 - Forum software by © MyBB