Menu

Showing posts with label layout. Show all posts
Showing posts with label layout. Show all posts

Thursday, December 26, 2019

[Laravel - Blade Template] การสร้าง Layout และการ Extend Layout
[Laravel - Blade Template] How to Create and Extend Layout

การสร้าง Layout

การสร้าง Layout เป็นการสร้างเว็บเพจด้วย HTML เช่นเดียวกับหน้าเว็บทั่วไป แต่แทนค่าส่วนต่างๆที่จะใช้โดย child view ด้วย directives ซึ่งมี directives ที่เกี่ยวกับ Layout ดังนี้
  • @section ใช้ประกาศ section ในส่วนของเนื้อหา
  • @show ใช้ประกาศ section และใช้แสดงเนื้อหาของ section นั้น
  • @yield ใช้แสดงเนื้อหาของ section ที่ระบุ
ตัวอย่าง เช่น
@section('sidebar')
    This is the master sidebar.
@show

<div class="container">
    @yield('content')
</div>