Support the ongoing development of Laravel.io →
Views Blade Laravel.io
Last updated 2 years ago.
0

Hi destructor,

There is nothing wrong with the route, the issue is with the view. Since i do not see what you did with your view here let me put what you have said into perspective and give you what i think is going wrong.

I can see your index.blade.php is being loaded for the request. Additionally, you've said you have master template somewhere which index is extending <-- possible issue. And in you master template which index is extending, you have a ~~~ @yield('content') ~~~

Essentially one of the two things is happening

  1. You forgot to extend the master template, therefore, since styles and everything are in master template they will never be carried forward, to fix this you must extend the master template in your index.blade.php ~~~ @extends('your.master.template')~~~

In the case above styles will not output at all since there is no reference to any styles whatsoever.

  1. Another thing that can happen is that, you've linked everything correctly including extending the master template (assuming master template does not output any contents beside adding the styles)... And you've properly defined and area where the injecting template data would be yielded by the defined ~~~ @yield('content') ~~~ (in your case). To have the data parsed you must define the section in your index file.

**What you views should look like**
I am assuming you main master layout is in layouts directory and obviously as you've noted above your index.blade.php is at the root.

*layouts/main.blade.php should look like this:*


<!DOCTYPE html> <html> <head> title, style sheets... anything else </head> <body> @yield('content') </body> </html> ~~~

And your index.blade.php should look like this:

@extends('layouts.main')

@section('content')
@stop

0

Thanks for answer sp01010011 ;) I saw that I was using @endsection instead of @stop so I chaged it but it not helped. My layouts/main.blade.php look like this:

<!DOCTYPE html>
<html>
  <head>
    title, style sheets... anything else
  </head>
  <body>
    @yield('content')
  </body>
</html>

My index.blade.php look like this:

@extends('layouts.main')

@section('content')
<div class="container">
  Page
</div>
@stop

And style not working, what can be wrong here?

0

Hmm, I fixed it :) Very strange is that when I was using:

<link href="css/bootstrap.min.css" rel="stylesheet">

instead of:

{!! Html::style('css/bootstrap.min.css') !!}

style in some pages was dissapearing, but {!! Html::style('css/bootstrap.min.css') !!} fixes it.

0

Hi Destructor, you're most welcome.

By the way, you could use either @stop or @endsection, i always tent to go with shortest way.

As for the styles, you're absolutely right, i was thinking all you were seeing was a white page without error or data. Any who, you could also do this:

<link rel="stylesheet" type="text/css" href="{{ asset('css/bootstrap.min.css') }}">

Personally, i prefer write things myself instead of having some of the code automatically generated. use the asset() method to link to public folder.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.