AtomCoder's avatar

Blade Template Issue

Hi there (hope this is in correct section, my first post),

In the main "app.blade.php" template file I've added a custom "@yield('nav')" in addition to the default "@yield('content')". But when I try to extend the layouts.app within navigation.blade.php file, for some reason its not displaying the navigation template within "@yield('nav')".

You guys got any ideas ?

0 likes
5 replies
AtomCoder's avatar

Yes I've read the documentation. Heres the code in app.blade.php

<nav id="main_navigation">

      @yield('nav')

    </nav>

    <section id="main_container">

      @yield('content')

    </section>

And here's the code on navigation.blade.php

@extends('layouts.app')

@section('nav')
 Display this text...
@endsection

The content yield works as it should, but the nav yield is not working.

tomopongrac's avatar

you put nav in app.blade.php but you extend layouts.app

1 like
WebKenth's avatar
WebKenth
Best Answer
Level 16

My guess is you are not viewing the navigation.blade.php file

Show us your route

And just a bonus, are you trying to separate your navigation from your main template? in that case you are not supposed to use @yield, but rather @include

This looks like you are trying to create a new navigation on each page using the layout

1 like
AtomCoder's avatar

@WebKenth Infact I was trying to do the opposite, I was trying to use the navigation throughout the entire website, which is exactly what app.blade does by default. I'm so dumb it's unreal. All I need to do is construct my nav in app.blade.

Thank you both for you help, i'll exit this discussion with my tail between my legs and feeling a little embarrassed.

Thanks again!

Please or to participate in this conversation.