Answer the question
In order to leave comments, you need to log in
Laravel 5.2 Is it possible to get meta from BLADE template? (title, keywords)?
Is it possible to get the meta from the BLADE template? (title, keywords) ?
For example, the structure is as follows:
index consists of
include header
create content
include sidebar
include footer
So, it turns out the sidebar appears on any page. How can I get meta titles in it without using js ?
The router references the template. At the moment of connecting the content of a certain page, I do this:
The router refers, for example, to index, the content in it is:
@section('title', 'title here')
@section('description', 'description here')
@include('layouts .header')
@include('layouts.sidebar')
@include('layouts.footer')
So,Catch maetategs?
Answer the question
In order to leave comments, you need to log in
Probably the best solution would then be like this:
You can also pass an array of data to the included template:
@include('view.name', ['some' => 'data'])
It turns out something like this:
<?php $title = Here title'; ?>
@section('title', title)
@include('view.name', ['title' => 'title'])
And in the name section we can get our variables.
In Bitrix, it is done in such a way that it is quite convenient. Each directory contains a .sections.php file.
It contains meta data.
In fact, such logic can be implemented using view ()-> share ()
That is, before the output of the desired view, we take the data from the desired .sections.
The second option is more convenient in terms of SEO maintenance.
But don't write meta in the controller, that's for sure! Then it will be possible to go crazy in terms of servicing the CEO
. Who are the pros and cons? Any other suggestions?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question