USE A LAYOUT/TEMPLATE ON A VIEW/BLADE IN LARAVEL

Published: 28 February 2023
on channel: Leo Paliuanan
326
4

Topic: how to use a layout/template on a view/blade in or using Laravel


Important notes to consider:

please make sure to watch and complete the video below before going to the process of this video..



   • INSTALLING LARAVEL AUTH-UI VUE (LOGIN...  
INSTALLING LARAVEL AUTH-UI VUE (LOGIN REGISTRATION WITH DASHBOARD) (P1)

make sure that you have finished with this video to have better understanding of what we are working right now.. LOL


Steps: lets get started


1 open xampp - start apache and mysql
2 open vscode - open current laravel project installed/created

the current laravel project is installed with the AUTH-UI vue - it has a login and register in it..
this also includes a dashboard, but its empty at the moment

we do still have our previous output from the previous video created

to today we will make use of a template or layout and apply it to our webpages called products and about the store

obviously, the 2 blade files dont have a template on them so we will try to make use one



3 go to layouts folder located at resources - views

create a copy of the app.blade.php and rename it to mylayout.blade.php





4 we will change the over-all look of the mylayout.blade.php using bootstrap that makes it much easier and faster for us ...

note: Laravel when installed with AUTH - UI vue already comes with a asset the comes with the latest version of front-end like bootstrap but as of today it is using a vite for its front-end

will remove all content inside body and add my own...

make sure to leave the @yield('content')
lets have a narbar on w3schools






5 lets use this template/layout for our remaining blades - products and about the store
goto resources - views and open products.blade.php

remove all HTML entities except the content of the webpage starting from the body
tag

goto home.blade.php, copy the code for @extends and @section and paste it on the code at the top of the products.blade.php

then on the bottom of the blade add @endsection




6 lets test the app - run php artisan serve..

its using a different layout ...

lets double check the file name of the layout we should be using for our blade.
change @extends('layouts.app) to @extends('layouts.mylayout')



7 lets do the same for the about the store blade
open aboutstore.blade.php
remove all HTML codes except the one inside the body tag - or the content of the page



and add the ff:
@extends('layouts.mylayout')
@section('content')

add these lines at top of the code


@endsection

add this line at the bottom of the code






8 lets test again..

you should have a template showing on the blades - products and about the store


Watch video USE A LAYOUT/TEMPLATE ON A VIEW/BLADE IN LARAVEL online without registration, duration hours minute second in high quality. This video was added by user Leo Paliuanan 28 February 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 326 once and liked it 4 people.