Laravel 5.1模块化刀片模板



我正在使用Laravel 5.1的模块化结构http://ziyahanalbeniz.blogspot.com.tr/2015/03/modular -结构- - laravel 5. - html

实际上我有一个模块用户,它具有以下结构:

——控制器

——模型

——翻译

——视图
-> index.blade.php
-> register.blade.php

在我的视图目录中,我有一个index.blade.php文件和一个register.blade.php文件。在我的index.blade.php文件中我使用:@include('register')以便将注册文件包含在我的索引PHP文件中。但是当调用我的索引文件时,我得到一个未发现异常的视图。

我有一些麻烦,这是我必须在@include中添加的正确路径。@include('user.register')也不起作用。什么好主意吗?谢谢你

您应该包括相对于resources/view的路径(无论您从哪里调用),用"."s替换"/"s。

例如:

yourproject/resources/views/template.php
yourproject/resources/views/module1/main.php
yourproject/resources/views/module1/foo.php
yourproject/resources/views/module2/main.php
yourproject/resources/views/module2/bar.php

应该包含在:

@include('template');
@include('module1.main');
@include('module1.foo');
@include('module2.main');
@include('module2.bar');

请记住,当您使用@include时,它会对文件进行文字复制,就像您复制并粘贴它一样。@include不扩展文件,所以你不能替换@yield@section标签,当你使用它。

换句话说,调用文件成为父文件。如果你想建立一个子视图,你应该使用@extends

欢呼

最新更新