CodeIgniter Forums
About layout creation with renderSection - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: About layout creation with renderSection (/showthread.php?tid=74450)



About layout creation with renderSection - edica - 09-24-2019

For the more experienced ...  Blush
Is it worth using "renderSection()" instead of just "echo view()"?

https://codeigniter4.github.io/CodeIgniter4/outgoing/view_layouts.html


RE: About layout creation with renderSection - includebeer - 09-29-2019

It makes more sense to use a template with renderSection() and echoing only one view in the controller than having to echoing a view for the header, then your content, then the footer, etc.


RE: About layout creation with renderSection - edica - 10-02-2019

Is it possible to cache the layout? Example: cache($this->extend('layouts/layout_site'))

<?= $this->extend('layouts/layout_site') ?>
<?= $this->section('content') ?>
<h1>Hello World!</h1>
<?= $this->endSection() ?>


RE: About layout creation with renderSection - includebeer - 10-04-2019

You can cache the whole page with $this->cachePage($n);
https://codeigniter4.github.io/userguide/general/caching.html


RE: About layout creation with renderSection - edica - 10-04-2019

Yes. Very good cachePage(). But it caches the whole page. And it works only within methods.
I wanted the cache only in $this->extend() which would be the layout.