Welcome Guest, Not a member yet? Register   Sign In
About layout creation with renderSection
#1

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

https://codeigniter4.github.io/CodeIgnit...youts.html
Reply
#2

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

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() ?>
Reply
#4

You can cache the whole page with $this->cachePage($n);
https://codeigniter4.github.io/userguide...ching.html
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#5

(This post was last modified: 10-04-2019, 06:59 AM by edica.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB