Hướng dẫn javascript in blade laravel
Show Chuẩn bị cần cho Blade template
myproject
Click vào dấu [+] để xem cấu trúc. Thực hiệnLần lượt tạo các file trên với nội dung như sau: Chú ý là chỉ làm mẫu cho trang News thôi, còn trang Product thì các bạn dựa vào trang News để làm thêm nhé. header.blade.php
footer.blade.php tpl_default.blade.php
news.blade.php
Kết nối trang Views và Templates
tpl_default.blade.php
news.blade.php @extends('templates.tpl_default') @section('content')
Hiển thị trình duyệtTiêu đề từ templateTin trong ngàyNội dung siêu ngắn cho tin tức mới đây!!!
Kết nối nhiều nội dung từ Views vào Templates
tpl_default.blade.php
news.blade.php @extends('templates.tpl_default') @section('css') @endsection @section('content')
Truyền giá trị từ trang Views vào Template
news.blade.php Truyền giá trị @extends('templates.tpl_default', ['pageId' => 'news']) @section('css') @endsection @section('content') tpl_default.blade.php Nhận giá trị
Cách gọi Hiển thị trình duyệtTiêu đề từ templateTin trong ngàyNội dung siêu ngắn cho tin tức mới đây!!!
DownloadCác bạn download những file code đã tạo để tham khảo nhé Blade Template, nội dung bao gồm các file routing, controller, ... |