CodeIgniter Forums
Two controller for one view - 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: Two controller for one view (/thread-33397.html)



Two controller for one view - El Forum - 08-24-2010

[eluser]jis[/eluser]
how to write two controller for a single view is that possible if it possible pls giv me some examples.......


Two controller for one view - El Forum - 08-25-2010

[eluser]umefarooq[/eluser]
as in CI one controller is called at a time and you can call view for controller two controller for example you have called page controller you can just simply load the view

sitename.com/page/test

later you called

sitename.com/gallery/test

now you have called gallery controller now you can call you view here also


Two controller for one view - El Forum - 08-25-2010

[eluser]Bramme[/eluser]
I think you misunderstood jis' question, umefarooq.

However jis, like umefarooq said: CI calls one controller at a time. Therefore it is (with Vanilla CI, afaik) impossible to use two controllers to manage one view.

I would suggest placing the functionality you need from the two controllers into a library or helpers.


Two controller for one view - El Forum - 08-25-2010

[eluser]jis[/eluser]
ok thank you guys..as i said erliar i am a bigginer now i need to use the form validation and upload funtion from the library i wrote these as separete functio in controller how i call these in in the view page ..??


Two controller for one view - El Forum - 08-26-2010

[eluser]Bramme[/eluser]
As I see it, you're having problems grasping some basic OO principles. I suggest you read up on it (plenty of tutorials/good books out there!)

You're trying to puzzle one view together with multiple controller methods where it's actually the other way around: one controller method will puzzle together multiple views (like header.php, content.php and footer.php) to create a webpage.