CodeIgniter Forums
Sidebars and sub-controllers.. - 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: Sidebars and sub-controllers.. (/thread-42290.html)



Sidebars and sub-controllers.. - El Forum - 06-02-2011

[eluser]Korhal[/eluser]
Hey guys,

I am very new to code igniter having started my first project only a week or two back. I have one main problem currently which I am struggling to find an answer I can use. Here goes..

I have a view which currently calls a common sidebar view on most of my pages. I am incorrectly (i know) calling data from models to populate this sidebar. As the sidebar is shared over many pages i do not have to remember to tell each controller to pass this data to the view.

Now i am running into a problem where i need to make the controller dynamic.. IE.. The forum, news pages and user management pages all need unique sidebars while the rest of the pages still require the default one.

My own thought was to have the controller call another controller named sidebar object buffering the output, which then could be passed down to the view when the main page is rendered.. After some research i am told this breaks the MVC pattern..

So now i am at a loss.. How should this be done? Please remember im a noob Smile.

Thanks in advance..
Korhal


Sidebars and sub-controllers.. - El Forum - 06-02-2011

[eluser]InsiteFX[/eluser]
Do a search for HMVC and Widgets.

InsiteFX


Sidebars and sub-controllers.. - El Forum - 06-02-2011

[eluser]Pascal Kriete[/eluser]
If you wanted to do this natively, the easiest solution is to create a sidebar library and then just call the corresponding method in there.


Sidebars and sub-controllers.. - El Forum - 06-03-2011

[eluser]Korhal[/eluser]
Why did I not think of that.. Thank you, i will give both ideas a try..

Lee