EllisLab text mark
Advanced Search
     
Parser Library
Posted: 11 November 2012 04:26 PM   [ Ignore ]
Joined: 2012-03-06
38 posts

Hi all,

is it possible to also load view files within a template view file?

my template.php file contains navigation and there’s 1 section that changes accordingly to the link clicked.
So I don’t only need to pars {title} and stuff, but also the view file belonging to the link.

Thanks in advance!

 
Posted: 11 November 2012 04:34 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

Yes, this is possible. You can have lines like this in any of your views

$this->load->view('another/view'); 

though you need to be careful because of possible changes in the scope of $this. It’s actually better to load your views in the controller and assign the “sub”-views a variable which will just be echoed in your view:

controller:

$sub_view $this->load->view('path/to/sub/view'NULLTRUE);

$this->load->view('path/to/main/view', array('sub_view' => $sub_view)); 

path/to/main/view:

// all your other code here

echo $sub_view;

// all the rest of the other code here 
 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess

 
Posted: 11 November 2012 04:44 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-03-06
38 posts

I just came across this: http://www.jenssegers.be/blog/25/Codeigniter-template-library
Think I might give it a shot…