How do I embed views within views? Nested templates? Header, Main, Footer (Blocks) design? Partials? Page Fragments? Ruby on Rails style Yield functionality?

Answer

There are several other described ways to deal with this problem:

Version 1.6 (Released January 31, 2008) has support for multiple views. See the User Guide for more details. That change to the core makes some of these approaches "old school" (as it were). This forum thread covers some good ground: http://codeigniter.com/forums/viewthread/87346/

First, basic information on views and the optional third 'return' parameter: http://www.codeigniter.com/wiki/Displaying_Multiple_Views/ and also, The CI Loader class documentation page

Coolfactor's View Library is one solution to nesting views in a tidy way. http://codeigniter.com/forums/viewthread/49910/

Gyorgy Fekete's View library similar to Coolfactor's with the differences spelled out in the thread. http://codeigniter.com/forums/viewthread/62521/

Another place to get advice if you don't want to add a new library is Rick Ellis' original thread on the subject (Embedding Views within Views). http://codeigniter.com/forums/viewthread/44916/

Also, teamhurting has implemented a Ruby On Rails style Yield approach that uses CI's hooks system: Yield using hooks - http://codeigniter.com/forums/viewthread/57902/

Another similar approach using a basic class rather than a class as a hook: http://codeigniter.com/wiki/layout_library/

A thread where esra lists a few threads on this topic: http://codeigniter.com/forums/viewthread/57965/

A Rails-Style ActionView library and helper called Ocular has a web page wiki here: http://codeigniter.com/wiki/Ocular_Layout_Library/ and a thread here: http://codeigniter.com/forums/viewthread/65050/

A thread for a View library (author tested with Matchbox) http://codeigniter.com/forums/viewthread/67028/

All CODEIGNITER Questions

Ask your interview questions on codeigniter

Write Your comment or Questions if you want the answers on codeigniter from codeigniter Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---