Welcome Guest, Not a member yet? Register   Sign In
View (that receivs data from database) in another view?
#1

[eluser]axed[/eluser]
Hi,

I'm a CodeIgniter beginner.
My question is how do i include a view A, that receives data from a database, in another view B? I understand that i can load the view A in the other view B but how do i get the function that handles the database request and then in normal case loads the view A to also run when view A is loaded into view B?

I hope you can understand what i'm trying to describe..
Once i saw that the framework CakePhp had a function named requestAction. I think it's the similar functionality i'm trying to accomplish. Can i just run something like this->controller->function (if this function is loading the view that i want to include) in the view or is this wrong?

I've tried to search the forum to find topics about views but all i can find is answers how to include "static" views in other views. As i write above i want the content of the included view to be dynamic from a database or similar.

//Dan
#2

[eluser]jedd[/eluser]
[quote author="axed" date="1260057822"]
I've tried to search the forum to find topics about views but all i can find is answers how to include "static" views in other views. As i write above i want the content of the included view to be dynamic from a database or similar.
[/quote]

Hi Dan and welcome to the CI forums.

Do you mean load a sub-page on each page (browser) refresh? If so, read this wiki article and then neighbouring articles, and search the forums for 'header footer'.

[url="/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]header & footer on every page[/url]

If you mean you want to load a sub-view without disturbing the rest of the page - that is, an AJAX-ish call - then you need to look at javascript, and that works much the same in CI as it does in conventional PHP programming - the only difference is where you put your various files.
#3

[eluser]axed[/eluser]
Hi again and thanks jedd for the reply.
I've checked the page you linked to and i think i understand quite a bit more now!




Theme © iAndrew 2016 - Forum software by © MyBB