Reputation: 397
My yield or section is not working here is my code i think i already follow all the rules. As you can see I want to call the home.blade.php i name it as a @section('content-page') and call it to the main.blade.php using yield('content-page') but it seems the yield or section is not working. here are my codes below:
home.blade.php
@extends('layouts.masters.main')
@section('page-content')
@include('layouts.partials.nav')
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="../custom/image/image-slider/1.jpg">
</div>
<div class="item">
<img src="../custom/image/image-slider/2.jpg">
</div>
<div class="item">
<img src="../custom/image/image-slider/3.jpg">
</div>
<div class="item">
<img src="../custom/image/image-slider/4.jpg">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div id="news-container">
<h2>News</h2>
<div class="strike">
<span>Latest</span>
</div>
<div class="container">
<div class="row">
<div class="col-sm-4">
<figure>
<img src="../custom/image/image-slider/3.jpg" height="300px;" width="100px;">
<figcaption>
<h3>I love this title!</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p><a href="../news/new.php">Read More</a></p>
</figcaption>
</figure>
</div>
<div class="col-sm-4">
<figure>
<img src="../custom/image/image-slider/2.jpg" height="300px;" width="100px;">
<figcaption>
<h3>I love this title!</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p><a href="../news/new.php">Read More</a></p>
</figcaption>
</figure>
</div>
<div class="col-sm-4">
<figure>
<img src="../custom/image/image-slider/1.jpg" height="300px;" width="100px;">
<figcaption>
<h3>I love this title!</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p><a href="../news/new.php">Read More</a></p>
</figcaption>
</figure>
</div>
</div>
</div>
</div>
<div id="about-container">
<h2>About</h2>
<div class="strike">
<span>Our Story</span>
</div>
<p>
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form,
</p>
</div>
<div id="contact-container" style="background-color: whitesmoke;">
<h2>Contact</h2>
<div class="strike">
<span>Our Contact</span>
</div>
<div class="container" style="padding: 35px;">
<div class="row">
<div class="col-sm-6" style="background-color: whitesmoke; padding: 10px;">
<form>
<div class="form-group">
<label for="name">Name:</label>
<input type="name" class="form-control" id="name" required id="name-textfield">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" required id="email-textfield">
</div>
<div class="form-group">
<label for="message">Message:</label>
<textarea type="message" class="form-control" rows="4" cols="50" required id="message-textarea">
</textarea>
</div>
<button type="submit" class="btn btn-default">Send</button>
</form>
</div>
<div class="col-sm-6" style="padding: 10px;">
<div class="form-group">
<label >Address</label>
<p>O4F Vasile milea Blvd.Afi Park 2 Bucharest 6 Romania 061344</p>
</div>
<div class="form-group">
<label >Phone</label>
<p> +46 (0)31 33 35 000</p>
</div>
<div class="form-group">
<label >Email</label>
<p>[email protected]</p>
</div>
</div>
</div>
</div>
</div>
@include('layouts.partials.footer')
@stop
the route code
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [
'as' => 'home',
'uses' => 'PagesController@home'
]);
The PageController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PagesController extends Controller
{
public function home()
{
return view('layouts.masters.main');
}
}
And Lastly my main.blade.php
<!DOCTYPE html>
<html>
<head>
<title>
Forester | Home
</title>
<link rel="stylesheet" href="../custom/bootstrap/css/bootstrap.min.css">
<!-- <script src="../HCI/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script> -->
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="../custom/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="../custom/css/css.css">
</head>
<body>
<div class="col-xs-12">
@yield('page-content')
</div>
</body>
</html>
Upvotes: 1
Views: 2536
Reputation: 4153
In your controller, you must change return value to "layouts.masters.home" (instead of "layouts.masters.main").
And in your view directory you must have a directory called "masters" and inside it you must have "main.blade.php" and "home.blade.php"
Upvotes: 1
Reputation: 390
Not sure if that's the problem, but you're missing the @endsection
tag at the end of your home.blade.php
file
Upvotes: 1