Php Laravel 4.1文件夹布局在视图文件夹中不可用
Laravel 4.1是否在Php Laravel 4.1文件夹布局在视图文件夹中不可用,php,laravel-4,Php,Laravel 4,Laravel 4.1是否在视图中带有布局文件夹,还是应该手动创建 我自己做了一个,但是现在我的模板不起作用了 仅供参考,安装了Laravel和composer 我想实现以下代码模板,包括2个文件: user.blade.php(placed in app/views/layouts/user.blade.php) <!doctype html> <html> @section('lib') <head>
视图
中带有布局
文件夹,还是应该手动创建
我自己做了一个,但是现在我的模板不起作用了
仅供参考,安装了Laravel和composer
我想实现以下代码模板,包括2个文件:
user.blade.php(placed in app/views/layouts/user.blade.php)
<!doctype html>
<html>
@section('lib')
<head>
<meta charset="utf-8">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap
/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
table form { margin-bottom: 0; }
form ul { margin-left: 0; list-style: none; }
.error { color: red; font-style: italic; }
body { padding-top: 20px; }
</style>
</head>
@stop
<body>
<div class="container">
@if (Session::has('message'))
<div class="flash alert">
<p>{{ Session::get('message') }}</p>
</div>
@endif
@yield('main')
</div>
</body>
</html>
user.blade.php(放在app/views/layouts/user.blade.php中)
@节(“lib”)
表格形式{页边距底部:0;}
表单ul{左边距:0;列表样式:无;}
.错误{颜色:红色;字体样式:斜体;}
正文{padding top:20px;}
@停止
@if(会话::has('message'))
{{Session::get('message')}
@恩迪夫
@产量('main')
我想将它实现为index.blade.php(app/views/user/index.blade.php)
@extends('layouts.user'))
@第节(“标题”)
@展示
所有用户
{{link_to_route('users.create','addnewuser')}
@如果($users->count())
用户名
密码
电子邮件
电话
名称
@foreach($users作为$user)
{{$user->username}
{{$user->password}
{{$user->email}
{{$user->phone}
{{$user->name}
{{link_to_route('users.edit','edit',',
数组($user->id),数组('class'=>'btn btn info'))}
{{Form::open(数组('method'
=>'DELETE','route'=>array('users.destroy',$user->id))}
{{Form::submit('Delete',array('class'
=>'btn btn danger'))}
{{Form::close()}}
@endforeach
@否则
没有用户
@恩迪夫
@展示
当我覆盖它时,它不工作。哪一条线或流程错误?您希望在“视图”中的一个名为“布局”的文件夹中存储您的布局相关视图吗?是的,根据其官方网站上的Laravel文档,master.blade.php存储在layouts文件夹中。那么它是手动创建的还是默认情况下laravel提供的?您在哪里调用/使用/扩展模板?你能用你使用的代码编辑你的答案吗?当然,我会编辑immediately@Webinan谢谢你的参与,我已经解决了我的问题。我认为布局文件夹包括安装时。但当我再次尝试创建此文件夹后,它就可以工作了。
@extends('layouts.user')
@section('head')
@show
<h1>All Users</h1>
<p>{{ link_to_route('users.create', 'Add new user') }}</p>
@if ($users->count())
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Phone</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->username }}</td>
<td>{{ $user->password }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->phone }}</td>
<td>{{ $user->name }}</td>
<td>{{ link_to_route('users.edit', 'Edit',
array($user->id), array('class' => 'btn btn-info')) }}</td>
<td>
{{ Form::open(array('method'
=> 'DELETE', 'route' => array('users.destroy', $user->id))) }}
{{ Form::submit('Delete', array('class'
=> 'btn btn-danger')) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
@else
There are no users
@endif
@show