0

Excuse me, i would like to ask about how to call another page blade in different subfolder inside views. Example :

views
   --home(subfolder)
   --beranda(subfolder)
       --refresh.blade.php
   --layouts(subfolder)
       --master.blade.php

in master.blade.php implements template page, when i click one link in this folder may have to go in refresh.blade.php. Likely another web layout, they have a lot of link in header like 'Home', 'Paper', etc.

I'm still learned more about laravel as beginner practice. May you can help me, i'll appreciate that.

Regard, Aga.

agawmd
  • 33
  • 3
  • 9
  • Further reference : https://stackoverflow.com/questions/31473978/laravel-5-keep-views-and-models-in-separate-folder-in-resources-views-directory?rq=1 – Marylyn Lajato Feb 25 '18 at 01:20
  • Thank you, it really help me... i just confused how to explain what i mean – agawmd Feb 25 '18 at 01:34

1 Answers1

0

I think you can refer to some directives such as @include and @extends in the laravel blade.

For example, in the admin.common.header view (located at admin/common/header.blade.php), we have some basic page code (common to various pages such as navigation bar or layout). We use @yield such as @yield ("extra_js") or @yield ("extra_css") where we want to add code later.

header.blade.php

<html>
    <head>
        something maybe ...
        @yield("extra_css")
    </head>
    <body>
        something maybe ...
        @yield("extra_js")
    </body>
</html>

And in another view such as admin.feedback.feedback, you can use @extends('admin.common.header') at the top of the code to inheritance the template and you will get the layout of this template. For different content in the feedback template, you can use @section to give you code to fill in the inheritance template such as @section('extra_js').

feedback.blade.php

@extends('admin.common.header')
@section('extra_js')
<script> something... </script>
@endsection

If you want to include one blade, just use @include.

<div>
    @include('shared.errors')

    <form>
        <!-- Form Contents -->
    </form>
</div>

In laravel blade there are many instructions to complete the rendering of the template, if you want to know clearly, please refer to the corresponding version of the official document.

Henry
  • 176
  • 6
  • code is successful but the view of this link is under the contents of the file in the click – agawmd Feb 25 '18 at 03:35