Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
CodeIgniter

Creating Layouts and Templates in CodeIgniter

Build reusable layouts with sections/extends (view layouts) to avoid duplicated HTML.

Creating Layouts and Templates in CodeIgniter — a practical guide to CodeIgniter layouts with clear examples you can reuse in real projects.

CodeIgniter Tutorial Series (16/74). Prefer one article? Read the complete CodeIgniter tutorial.

Short description

CI4 supports view layouts so header/footer stay in one place while each page fills content sections.

Layout + page

<!-- Views/layout.php -->
<html><body>
  <?= $this->renderSection('content') ?>
</body></html>

<!-- Views/about.php -->
<?= $this->extend('layout') ?>
<?= $this->section('content') ?>
  <h1>About</h1>
<?= $this->endSection() ?>

Leave a reply

Your email address will not be published. Required fields are marked *