当用户浏览网站上的不同页面时,我需要将特定脚本添加到页脚模板。Laravel 5将路径传递到视图作曲器的模板
我使用:
public function boot()
{
view()->composer('partials.jsinclude',function($view)
{
$view->with('variable',{{how to pass the route here}});
});
}
我的页脚模板:
<section id="footer-top" class="section">
<!-- Start Footer -->
<footer class="footer">
//some code here:
</footer>
</section>
<!--/ End Footer -->
@include ('partials.jsinclude')
因此,例如当用户 博客/ taylor_swift页面上,将仅包含博客脚本文件/ js/taylor_swift在脚本的末尾部分模板
如何将partials.jsinclude
模板传递给查看器的当前页面是这样,例如 “博客” 和 “taylor_swift” 当用户nagivates到mypage.com/blogs/taylor_swift
您是否想要为这两个页面添加'partials.jsinclude'或你想传递数据给它 –
我想传递数据给它,特别是控制器的名称和视图的名称。 – Edward