Home > front end >  Laravel: How to include external links in selected views
Laravel: How to include external links in selected views

Time:10-26

i have included all the css and js external links under <header> tag of my index view.

Now there are some external links which i want to load on selected views only,

i can add links separately on that view but that link will go out of <head> tag.

how can i load selected links on selected views only from <header> tag of index view.

i tried

<head>
...other links
     @if(View::exists('ispblade.calendar'))
            @include('ispblade.calendar_links')
        @endif 
</head>

but it's loading selected link on all views.

CodePudding user response:

You need to use stacks for that.

In Layout:

<head>
    <!-- Head Contents -->

    @stack('scripts')
</head>

In your view:

@push('scripts')
    <script src="/example.js"></script>
@endpush

https://laravel.com/docs/8.x/blade#stacks

  • Related