php - Include template is not showing content when page called? -


i want call content.blade.php both ajax , url direct calling ! if called ajax , don't want include master.blade because has jquery , many basic link ,it cause duplicate file ! when called direct link in browser , need include master.blade . content page not showing (eg.this content) when called direct url in browser ,ajax call has no problem !! how can solve ?

say test action,

public function test(request $request) {    return view("content",[ajax,$request->ajax()]); } 

master.blade.php

<html> <head> <title>@yield('title')</title> </head> <body> @section('sidebar') master sidebar. @show <div class="container"> @yield('content') </div> </body> </html> 

content.blade.php

@includewhen(!$ajax,"master") @section('content')   content @endsection 

it's not showing because you're calling @section('content') have no template yielding it.

you make layout without scripts don't want:

ajax.blade.php

@yield('content') 

and in content.blade.php, extend master.blade.php when it's not ajax or extend ajax.blade.php when it's ajax:

content.blade.php

@extends($ajax ? 'ajax' : 'master') @section('content')     content @endsection 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -