CodeIgniter Forums

Full Version: About layout creation with renderSection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For the more experienced ...  Blush
Is it worth using "renderSection()" instead of just "echo view()"?

https://codeigniter4.github.io/CodeIgnit...youts.html
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.
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() ?>
You can cache the whole page with $this->cachePage($n);
https://codeigniter4.github.io/userguide...ching.html
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.