samedi 4 mai 2019

Can't extend Blade template files in sub-folders with @yield and @section

In my resources\views folder I have splitted the views in two folders:

  1. resources\views\backend for Back-end / admin files
  2. resources\views\frontend for Front-end / public files

In my resources\views\frontend folder I have resources\views\frontend\home.blade.php file, which I have set as the Home page. Within it I have following code:

<!doctype html>
<html lang="en" class="no-focus">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="">

    <!-- SEO -->
    @yield('seo')

    <meta name="theme-color" content="#F21DAB" />
    <!-- Icons -->
    <link rel="icon" href="" type="image/x-icon">
    <link rel="shortcut icon" href="">
    <link rel="icon" type="image/png" sizes="192x192" href="">
    <link rel="apple-touch-icon" sizes="180x180" href="">

    <!-- Remote CSS -->
    <link rel="stylesheet" href="https://use.typekit.net/txa1mfr.css">
    <link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">

    <!-- Local CSS -->
    @yield('head_css')
</head>

Here I try to @yield seo and head_css @section.. so I have set new resources\views\frontend\content\home.blade.php file which contains following code:

@extends('frontend.home')

@section('seo')
    <title></title>
    <meta name="title" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="robots" content="noindex, nofollow">

    <!-- Meta -->
    <meta property="og:title" content="">
    <meta property="og:site_name" content="">
    <meta property="og:description" content="">
    <meta property="og:type" content="website">
    <meta property="og:url" content="">
    <meta property="og:image" content="">
@stop



@section('head_css')
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="">
@stop

The issue here is that while Laravel successfuly loads resources\views\frontend\home.blade.php it doesn't @yield and load @section from resources\views\frontend\content\home.blade.php.

I've tried everything and can't seem to find solution. Thanks in advance for help!



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2PL1hut
via IFTTT

Aucun commentaire:

Enregistrer un commentaire