php - include nested views if exists in blade, laravel 5 -
i trying include view if exists. have main page.blade.php should render content of selected page. in back-end of application flat array content in (id , name). if template exists want render first need check if template exists.
i got following code right now:
@foreach($flattenpage $page) @if(file_exists('templates.'.strtolower($page['name']))) @include('templates.'.strtolower($page["name"])) @endif @endforeach the problem won't through if statement. tried:
@if(file_exists('../templates/'.strtolower($page['name']).'.blade.php')) the current template views/page/show.blade.php , need render views/templates/mycontent.blade.php
if need determine if view exists - can use exists method (as described in docs)
@if (view()->exists('templates.'.strtolower($page["name"]))) @include('templates.'.strtolower($page["name"])) @endif
Comments
Post a Comment