kenjis / codeigniter-ss-twig

A Simple and Secure Twig integration for CodeIgniter 3.x and 4.x
MIT License
168 stars 46 forks source link

[Question] Only one display for function? #10

Closed xQuByte closed 8 years ago

xQuByte commented 8 years ago

Hi! I want to display Header, content and footer. When I use: $this->twig->display('Header'); Everythink works perfectly, but when i write below $this->twig->display('Footer'); i can see only footer etc.

I can see only last display in function.

kenjis commented 8 years ago

Yes, you can call display() only once. If you want to have more than one templates, you can do like this: https://github.com/kenjis/codeigniter-tettei-apps/blob/develop/application/views/shop_tmpl_shop.twig See Twig documentation: http://twig.sensiolabs.org/doc/templates.html#including-other-templates

Or you can get the output string with using rendar() method.

$output = $this->twig->render('welcome', $data);
xQuByte commented 8 years ago

Thank you for your reply. I always use this same header and footer so in every view i use {% include 'include/Header.twig' %} {# content #} {% include 'include/Footer.twig' %}