我正在尝试在我的laravel应用程序中实现动态元标记。我有一个head.blade.php文件,其中包含所有代码。这就是我一直在做的,我在pages文件夹下创建了一个名为meta-conf.php的文件,head.blade.php包含 -
@if(Route::currentRouteName() != false)
{{
$page = Route::currentRouteName();
}}
@include('pages.meta-conf');
{{
$title = $meta[$page]['title'];
$keywords = $meta[$page]['keywords'];
$description = $meta[$page]['description'];
}}
@else
{{
$title = "akademe";
$keywords = "";
$description = "Quickly find near by courses";
}}
@endif
meta-conf.php包含 -
<?php
$meta['index']['title'] = "Home";
$meta['index']['keywords'] = "explore, learn, repeat, education, register, institute, courses";
$meta['index']['description'] = "Quickly find near by courses";
现在它给我一个错误&#34;未定义的变量:meta&#34;。我已经包含了meta-conf.php文件,其中包含定义的$ meta数组,如上所示。什么导致了这个问题。
答案 0 :(得分:0)
我会做什么而不是你正在做的是:
app/Http/Controllers/Controller.php
)head.blade.php
以使用元变量我还没有对上述任何一项进行过测试,但认为这样的事情应该有效:)