How can i pass variable with section in main layout file?
Got this error while using @section('metatitle', {{$meta->title}) in index.blade.php
ErrorException (E_ERROR)
syntax error, unexpected '<' (View: index.blade.php)
Previous exceptions
syntax error, unexpected '<' (0)
You are missing the closing curly bracket after title
@section('metatitle', {{$meta->title}})
You don't use blade brackets inside a blade directive
@section('metatitle', $meta->title)
@sinnbeck , I've make a mistake while create discussion here, My code is same as you mentioned
@section('metatitle', {{$meta->title}})
hey @snapey
I've tried, it works fine with 2 variables with in a section, but when I'm create third section it will return an error
2 variables
@section('test1', {{$content}})
@section('test2', {{$content2}})
3rd variable
@section('test3', {{$content3}})
ErrorException (E_ERROR)
syntax error, unexpected '<' (View: index.blade.php)
Previous exceptions
syntax error, unexpected '<' (0)
Can you show that part of your code? It's kinda hard to guess the error from a single line of code
I've changed the code, but error is still same
@php
$titleMeta = $category->meta_title;
$descriptionMeta = $category->meta_description;
$keywordsMeta = $category->meta_keywords;
$created = $category->created_at;
$updated = $category->updated_at;
$imageURL = '/images/'.$category->image';
@endphp
@extends('layouts.app', ['titleMeta' => $titleMeta, 'descriptionMeta' => $descriptionMeta, 'keywordsMeta' => $keywordsMeta, 'created' => $created, 'updated' => $updated, 'imageURL' => $imageURL])
@section('content')
<div class="container">
</div>
@endsection
app.blade.php
<title>{{$titleMeta}}</title>
<meta name="description" content="{{$descriptionMeta}}"/>
<meta name="keywords" content="{{$keywordsMeta}}" />
The problem is that you have an extra ' here (after image)
$imageURL = '/images/'.$category->image;
You could in-line all those values rather than creating temporary variables
@extends('layouts.app', [
'titleMeta' => $category->meta_title,
'descriptionMeta' => $category->meta_description,
'keywordsMeta' => $category->meta_keywords,
'created' => $category->created_at,
'updated' => $category->updated_at,
'imageURL' => '/images/'.$category->image,
])
@section('content')
<div class="container">
</div>
@endsection
Please or to participate in this conversation.