CodeIgniter Forums
Multiple Views & Dynamic Data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Multiple Views & Dynamic Data (/thread-2493.html)



Multiple Views & Dynamic Data - El Forum - 08-08-2007

[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


Multiple Views & Dynamic Data - El Forum - 08-08-2007

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


Multiple Views & Dynamic Data - El Forum - 08-08-2007

[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);



Multiple Views & Dynamic Data - El Forum - 08-08-2007

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