Welcome Guest, Not a member yet? Register   Sign In
Controller A loading a view which has data from controller B
#1

[eluser]tobefound[/eluser]
Pretty self-explanatory:

Controller A is loading a view which presents data from controller B? How can this view get its data from controller B when I'm calling the view from A?

The problem comes from my site displaying multiple forms at the same page. For instance, I might have a login form visible at the same time as the registration page is visible (having the login form in a side panel).

Anyone can shed some light?

/Tommy
#2

[eluser]jedd[/eluser]
Hi Tommy and welcome to the CI forums.

Your best bet is to generate your 'view partial' in a common place, rather than in just one of your controllers (and then try to extract it from there each time).

My preference is to [url="http://ellislab.com/codeigniter/user-guide/general/core_classes.html"]extend the core Controller[/url] and put things like your login-form generator into it, load the view partial there too, and then you can access the resultant 'string of HTML' from any of your controllers.

I discuss this approach in some detail [url="http://codeigniter.com/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]in the wiki[/url], too.




Theme © iAndrew 2016 - Forum software by © MyBB