2
I am learning Laravel 5.1, I came across a mistake while using the @yield
. I can’t move the contents from another archive to the archive where I want to include.
Next I have the content I want to insert in the file default-home.blade.php
inside the layouts folder:
@extends('layouts.default-home')
@section('content')
<section id="feature_two">
<div class="container">
<div class="row">
<!-- Feature Two Description -->
<div id="feature_2_description" class="col-md-5 feature_description triggerAnimation animated" data-animate="fadeInLeft">
<h2>Super easy to customize and well detailed for beginners</h2>
<p>Vestibulum at est vel felis adipiscing tincidunt. Proin quis diam ac lectus pretium mollis interdum sed erat. Phasellus eget
neque eu ipsum laoreet suscipit tincidunt suscipit purus rutrum
</p>
<p>Etiam euismod, ligula nec volutpat tempor, risus lerisque tincidunt purus libero. Fusce tincidunt ligula, nec sagittis turpis</p>
</div><!-- End Feature Two Description -->
<!-- Feature Two Image -->
<div id="feature_2_image" class="col-md-7 feature_image text-right triggerAnimation animated" data-animate="fadeInRight">
<img class="img-responsive" src="img/thumbs/feature_two_img.png" alt="feature_two_img">
</div>
</div><!-- End row -->
</div><!-- End container -->
</section>
@stop
This is file with the @yield
inserted, the @includes
are working:
<body class="notransition" ng-app>
@include('layouts.head-home')
@yield('content')
@include('layouts.footer-home')
<div id="status"></div>
</body>
In this case, the site I’m developing uses the links in the menu to jump to another part of the site below, besides this content does not display the console presents this error every time I roll the page or click on the link for scrolling:
Uncaught Typeerror: Cannot read Property 'top' of Undefined
Routes.php file :
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('','Site\HomeController@home');
Route::get('/','Site\HomeController@home');
?>
Controller:
<?php
namespace App\Http\Controllers\Site;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class HomeController extends Controller {
public function home(){
return view('site/home'); //chamando a view home.blade.php
}
}
The second file that would be the
layouts/default-home.blade.php
?– gmsantos
Yes, it is the content of the default-home.php file.
– let
and how is the file name you want to include? is calling the correct file on your route ?
– gmsantos
Do I need to call on the route that part of the file? In case everything is on a single page and it happens the jumps to another part. My route file looks like this: Route::get(','Site Homecontroller@home'); Route::get('/','Site Homecontroller@home');
– let
I think it’s best to include your Routes.php file in the question, click [Edit] and enter it nicely.
– gmsantos
Ah! the error is in the controller. Swap the bar for a point.
return view('site.home');
. Laravel follows this convention for views– gmsantos