Reputation: 2715
I am using codeigniter for my website and I was wondering if I could load a view in a view without using PHP. So like a Template Parser, is it possible to run this code:
<div>
<?php $this->load->view('widget'); ?>
</div>
with plain text like:
<div>
{loadview:widget}
</div>
Tnx
Upvotes: 1
Views: 1348
Reputation: 102745
Sorry, but there's nothing built in to Codeigniter that does this. You'll have to look at using a third party template parser or write your own.
Some suggestions:
With CI's native template parser, you can assign a variable that contains the content:
$data['widget'] = $this->load->view('widget', NULL, TRUE);
$this->load->view('my_view', $data);
The third param as TRUE
buffers the output so you can use it in a variable without it printing. Then in your view:
<div>
{{widget}}
</div>
..but currently, CI's parser has very limited capabilities. I'd go with Twig or Smarty.
Upvotes: 1