Welcome Guest, Not a member yet? Register   Sign In
Newbie Question
#1

[eluser]jdav3579[/eluser]
Hi,
Sorry for the obviousness of this question, but I came across a thread on the forum that said you can load a view within a view using $this->load->view syntax within the view file. I tried this and it worked. Is this legitimate to do this or does it break the MVC model?

Also can I use libraries the same way such as language or table libraries within the view?

Cheers
John
#2

[eluser]Watermark Studios[/eluser]
Keep in mind that everything is being loaded through your application instance. Loading a view within a view within a view is perfectly fine. It may get messy, but it works. Some people like to generate a "wrapper" view that handles separate views for the header, content, and footers. I prefer to keep view control in my controller, so I wrote a helper that loaded the three views for me in one line with an array that accepted the page title, content view name, and content data.

As long as you load your libraries in your controller, you can use them in the views as well.

Thanks,

Ken
#3

[eluser]jdav3579[/eluser]
Thanks Ken - That's brilliant. Annoyingly I had written hacks to access data that I thought I could not have gotten at!
#4

[eluser]Watermark Studios[/eluser]
Ya...CI is a pretty cool framework. I've recently been working with WebObjects (Java Framework) and have really had to understand the various layers of the framework structures. I keep coming back to CI + DMZ or CI + Doctrine for my smaller projects because it is so easy to use. Best of luck!

Cheers,

Ken




Theme © iAndrew 2016 - Forum software by © MyBB