laravel 5.4 how to make page title with dynamic

后端 未结 3 1849
一生所求
一生所求 2021-02-14 05:02

ihave a route to get artists initial letter.

this is my route

Route::get(\'/artists/{letter}\', \'HomeController@showArtist\')->where(\'letter\', \'[         


        
相关标签:
3条回答
  • 2021-02-14 05:50

    You can pass selected letter value to Blade view like this:

    return view('front.list',compact('artists','letter'));
    

    instead of:

    return view('front.list',compact('artists'));
    

    And now in your view you can use:

    <title>Artists begging with {{ $letter }}</title>
    
    0 讨论(0)
  • 2021-02-14 06:07

    If this is your master page title below

    <head>
            <title>App Name - @yield('title')</title>
        </head>
    

    then your page title can be changed in your blade page like below

    @extends('layouts.master')
    
    @section('title', 'Page Title')
    
    @section('sidebar')
    @parent
    
    <p>This is appended to the master sidebar.</p>
    @endsection
    
    @section('content')
    <p>This is my body content.</p>
    @endsection
    
    0 讨论(0)
  • 2021-02-14 06:10

    First step : Add this code inside header Tag.

     <title> Website Name ( optional ) - @yield('title')</title>
    

    Second Step : Add below code inside dynamic Page.

    @section('title',  $data['metaTitle'])
    
    0 讨论(0)
提交回复
热议问题