<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[Catatan Harian: Tutorial CodeIgniter 4: Extend, Section, EndSection, Include, dan RenderSection}]]></title>
	<link>https://sharka.site/3blog/pages/view/61/tutorial-codeigniter-4-extend-section-endsection-include-dan-rendersection</link>
	<atom:link href="https://sharka.site/3blog/pages/view/61/tutorial-codeigniter-4-extend-section-endsection-include-dan-rendersection" rel="self" type="application/rss+xml" />
	<description><![CDATA[}]]></description>
		<item>
	<guid isPermaLink="true">https://sharka.site/3blog/pages/view/61/tutorial-codeigniter-4-extend-section-endsection-include-dan-rendersection</guid>
	<pubDate>Wed, 22 Oct 2025 17:09:41 +0800</pubDate>
	<link>https://sharka.site/3blog/pages/view/61/tutorial-codeigniter-4-extend-section-endsection-include-dan-rendersection</link>
	<title><![CDATA[Tutorial CodeIgniter 4: Extend, Section, EndSection, Include, dan RenderSection]]></title>
	<description><![CDATA[<div style="color:#222;font-family:'Poppins',sans-serif;line-height:1.7;margin:0 auto;max-width:900px;"><div style="background-color:#f1f5ff;border-radius:12px;box-shadow:0 4px 12px rgba(2,62,138,0.1);color:#023e8a;padding:25px;text-align:center;"><h2 style="font-size:22px;margin:0;">💻 <strong>Materi CodeIgniter 4: Extend, Section, EndSection, Include, dan RenderSection</strong></h2><p style="color:#014f86;font-size:14px;margin:10px 0 0;">Memahami cara kerja template view dan layout di CodeIgniter 4</p></div><div style="margin-top:20px;"><p>Dalam pengembangan web menggunakan <strong>CodeIgniter 4 (CI4)</strong>, konsep <i>template engine</i> membantu kita membangun tampilan yang konsisten di setiap halaman. CI4 menyediakan mekanisme sederhana namun kuat melalui penggunaan: <strong>Extend, Section, EndSection, Include,</strong> dan <strong>RenderSection</strong>.</p><div style="background-color:#fff8e6;border-left:4px solid #ffb703;border-radius:8px;margin-top:10px;padding:12px;"><p><strong>Tujuan Pembelajaran:</strong></p><ul style="margin-bottom:0;margin-right:0;margin-top:6px;"><li><p style="margin-left:18px;">Memahami konsep layout utama dan view turunan di CI4</p></li><li><p style="margin-left:18px;">Mengetahui fungsi <code>extend</code>, <code>section</code>, dan <code>include</code></p></li><li><p style="margin-left:18px;">Mampu menerapkan layout dinamis dengan <code>renderSection</code></p></li></ul></div></div><h3 style="color:#023e8a;margin-top:25px;">1️⃣ Extend — Menghubungkan View dengan Layout Utama</h3><p>Fungsi <code>$this-&gt;extend('nama_layout')</code> digunakan untuk menyatakan bahwa halaman tersebut mewarisi tampilan dari file layout utama. Biasanya layout utama berisi struktur HTML dasar seperti header, footer, dan menu navigasi.</p><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;?= $this-&gt;extend('layout/main') ?&gt;</pre></div><h3 style="color:#023e8a;margin-top:25px;">2️⃣ Section dan EndSection — Mendefinisikan Isi Konten</h3><p>Di dalam halaman turunan, kita mendefinisikan bagian konten yang akan ditempatkan pada area tertentu dari layout menggunakan:</p><ul><li><code>$this-&gt;section('nama_bagian')</code> → membuka blok konten</li><li><code>$this-&gt;endSection()</code> → menutup blok konten</li></ul><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;?= $this-&gt;extend('layout/main') ?&gt;

&lt;?= $this-&gt;section('content') ?&gt;
  &lt;h2&gt;Selamat Datang di Dashboard&lt;/h2&gt;
  &lt;p&gt;Ini adalah contoh halaman yang menggunakan layout utama.&lt;/p&gt;
&lt;?= $this-&gt;endSection() ?&gt;</pre></div><h3 style="color:#023e8a;margin-top:25px;">3️⃣ RenderSection — Menampilkan Bagian dari Halaman Turunan</h3><p>Pada layout utama, gunakan <code>renderSection('nama_bagian')</code> untuk menampilkan konten dari halaman turunan yang menggunakan section tersebut.</p><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;!DOCTYPE html&gt;
&lt;html lang="id"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;My Website - &lt;?= $this-&gt;renderSection('title') ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h1&gt;My Website&lt;/h1&gt;
        &lt;?= $this-&gt;include('layout/navbar') ?&gt;
    &lt;/header&gt;

    &lt;main&gt;
        &lt;?= $this-&gt;renderSection('content') ?&gt;
    &lt;/main&gt;

    &lt;footer&gt;
        &lt;p&gt;© 2025 Delta Marena&lt;/p&gt;
    &lt;/footer&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div><h3 style="color:#023e8a;margin-top:25px;">4️⃣ Include — Menyisipkan File View Lain</h3><p>Fungsi <code>$this-&gt;include('path/nama_file')</code> digunakan untuk memanggil potongan tampilan seperti <i>navbar</i>, <i>sidebar</i>, atau <i>footer</i> agar tidak ditulis berulang kali.</p><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;?= $this-&gt;include('layout/sidebar') ?&gt;</pre></div><h3 style="color:#023e8a;margin-top:25px;">5️⃣ Contoh Struktur File View</h3><div style="background-color:#f8fafc;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">/app/Views/
│
├── layout/
│   ├── main.php          ← layout utama
│   ├── navbar.php        ← komponen navigasi
│   └── sidebar.php       ← komponen sidebar
│
└── pages/
    └── dashboard.php     ← halaman yang extend layout</pre></div><h3 style="color:#023e8a;margin-top:25px;">6️⃣ Contoh Layout dan Halaman Lengkap</h3><div style="background-color:#e7f5ff;border-left:4px solid #4361ee;border-radius:8px;margin-bottom:10px;padding:12px;"><strong>📄 layout/main.php</strong></div><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;?= $this-&gt;renderSection('title') ?&gt;&lt;/title&gt;
  &lt;link rel="stylesheet" href="/css/style.css"&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;header&gt;
    &lt;?= $this-&gt;include('layout/navbar') ?&gt;
  &lt;/header&gt;

  &lt;main&gt;
    &lt;?= $this-&gt;renderSection('content') ?&gt;
  &lt;/main&gt;

  &lt;footer&gt;
    &lt;p&gt;© 2025 Delta Marena&lt;/p&gt;
  &lt;/footer&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div><div style="background-color:#e7f5ff;border-left:4px solid #4361ee;border-radius:8px;margin-bottom:10px;margin-top:15px;padding:12px;"><strong>📄 pages/dashboard.php</strong></div><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;?= $this-&gt;extend('layout/main') ?&gt;

&lt;?= $this-&gt;section('title') ?&gt;Dashboard&lt;?= $this-&gt;endSection() ?&gt;

&lt;?= $this-&gt;section('content') ?&gt;
  &lt;h2&gt;Selamat Datang di Dashboard&lt;/h2&gt;
  &lt;p&gt;Anda berhasil menggunakan Extend, Section, dan RenderSection dengan benar!&lt;/p&gt;
&lt;?= $this-&gt;endSection() ?&gt;</pre></div><div style="background-color:#e7f5ff;border-left:4px solid #4361ee;border-radius:8px;margin-bottom:10px;margin-top:15px;padding:12px;"><strong>📄 layout/navbar.php</strong></div><div style="background-color:#0f172a0a;border-radius:8px;border:1px solid #e8eefc;padding:12px;"><pre style="font-size:13px;margin:0;white-space:pre-wrap;">&lt;nav&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="/dashboard"&gt;Dashboard&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="/about"&gt;About&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/nav&gt;</pre></div><div style="border-radius:10px;border:1px solid #e6eefc;margin-top:25px;padding:14px;"><p><strong style="color:#023e8a;">Kesimpulan:</strong></p><p style="font-size:14px;margin:8px 0 0;">Dengan memahami dan menggunakan <code>Extend</code>, <code>Section</code>, <code>EndSection</code>, <code>Include</code>, serta <code>RenderSection</code>, Anda dapat membangun sistem template di CodeIgniter 4 yang efisien, rapi, dan mudah dipelihara. Struktur ini juga memudahkan kolaborasi dalam tim dan mempercepat proses pengembangan tampilan web.</p></div></div>]]></description>
	<dc:creator>Muh.Taqiuddin.S</dc:creator>		</item>
</channel>
</rss>
