我之前已经开发了Laravel项目,但不知怎的,我无法解决Blade问题。我的@section和@include都因某些原因无效。这是我的文件:
{
"name": "educo/laraecom",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"laravelbook/ardent" : "2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
<!DOCTYPE html>
<html>
<head>
<title>Sports Gears</title>
{{HTML::style(asset("/public/css/common"))}}
{{HTML::style(asset("/public/css/jRating.jquery"))}}
{{HTML::style(asset("/public/css/cart"))}}
{{HTML::style(asset("/public/css/bootstrap.min"))}}
{{HTML::style(asset("/public/css/font-awesome"))}}
{{HTML::style(asset("/public/css/jquery.raty"))}}
{{HTML::style(asset("/public/css/homestyle.css"))}}
{{HTML::script(asset('/public/js/jquery'))}}
{{HTML::script(asset('/public/js/jquery-ui.min'))}}
{{HTML::script(asset('/public/js/jquery.ui.autocomplete.min'))}}
{{HTML::script(asset('/public/js/jquery.raty'))}}
{{HTML::script(asset('/public/js/common'))}}
{{HTML::script(asset('/public/js/cart'))}}
</head>
<body>
<div class="header">
@include('sub.header')
</div>
<div class="container">
@yield('content')
</div>
<div class="footercontainer">
@include('sub.footer')
</div>
</body>
</html>
some menu based html goes here
some plain html content goes here
Route::get('/', "StaticController@index");
public function index(){
return View::make('static.index');
}
@extends('layouts.index')
@section('content')
{{HTML::style(asset("/public/css/jquery-ui.css", "stylesheet"))}}
{{HTML::style(asset("/public/css/jquery.autocomplete.css", "stylesheet"))}}
{{HTML::script(asset('/public/js/bootstrap.min'))}}
{{HTML::script(asset('/public/js/jquery.flexslider-min.js'))}}
<div class="clear"></div>
<div class="row">
<div class="content-box">
<div class="col-lg-12" style="height:370px">
<div class="col-lg-9 col-xs-12">
@include('sub.slider')
</div>
</div>
<div class="offerbar col-lg-12">
<div class="deal-heading col-lg-12">
<div class="col-lg-4">
<div class="divider" style="float: right;"></div>
</div>
<div class="col-lg-4">
<p>GET BEST DEAL</p>
</div>
<div class="col-lg-4">
<div class="divider" style="float: left;"></div>
</div>
</div>
</div>
</div>
@stop
<div class="slider">
<div class="flexslider">
<ul class="slides">
<?php
if (!$mainBanners->isEmpty()) {
foreach ($mainBanners as $banner) {
$filename = $banner->savedfilename;
$url = $banner->url;
?>
<li><a href="{{$url}}">{{HTML::image(asset("/public/banners/" . $filename))}}</a></li>
<?php
}
}
?>
</ul>
</div>
</div>
现在我在服务器上运行这样的url:http://localhost/laraecom
我得到一个空白页面。当我检查源html时,我得到类似的东西
<link media="all" type="text/css" rel="stylesheet" href="https://localhost/laraecom/public/css/jquery-ui.css">
<link media="all" type="text/css" rel="stylesheet" href="https://localhost/laraecom/public/css/jquery.autocomplete.css">
<script src="http://localhost/laraecom/public/js/bootstrap.min"></script>
<script src="http://localhost/laraecom/public/js/jquery.flexslider-min.js"></script>
<div class="clear"></div>
<div class="row">
<div class="content-box">
<div class="col-lg-12" style="height:370px">
<div class="col-lg-9 col-xs-12">
<div class="slider">
<div class="flexslider">
<ul class="slides">
这意味着我的@section
和@include
都无效
答案 0 :(得分:0)
在 app / views / static / index.blade.php 中,您在文件末尾有两个 @stop ,删除一个就可以了。
答案 1 :(得分:0)
我不是专家,因为我写了这个,但我已经多次查看了你的代码
看看被引用的内容我可以看到它确实包含了所有文件并按要求生成内容但是从我能看到它的部分导致问题就在这里
<?php
if (!$mainBanners->isEmpty()) {
foreach ($mainBanners as $banner) {
$filename = $banner->savedfilename;
$url = $banner->url;
?>
<li><a href="{{$url}}">{{HTML::image(asset("/public/banners/" . $filename))}}</a></li>
<?php
}
}
?>
按照您的代码,我可以看到它正在提取所有文件及其内容,这是正确的,但它正好在此PHP代码之前根据您从浏览器输出提供的示例进行剪切。
我不知道它在哪里获取这些信息但是尝试删除这个放入一些纯文本只是为了看它是否写出然后你可以看到模板是否有效并且从那里你可以判断它是否是PHP语句造成这个问题。
我无法判断if语句的用途或信息来自何处,因此我无法定义其输出应该是什么......
您也可以尝试PHP转储$ mainBanners以查看该变量中是否有任何内容。?
或者,如果需要进一步的帮助,您可以粘贴以及传递此信息的位置示例,并从浏览器中分享更完整的输出?