Laravel 4 blade template won't render whole page - php

I'm running into a weird issue where my page isnt' getting rendered in its entirety. The bottom bit is getting cut off and I'm not sure why.
I'd paste code, but it's a 3000+ line template im trying to implement.
I am doing it as follows in dashboard.master:
#include('dashboard.master.head')
...
#include('dashboard.master.header')
...
#include('dashboard.master.sidebar')
...
#include('dashboard.master.style_customizer')
...
#include('dashboard.master.page_header')
...
#yield('content')
...tons of lines here
It renders up to content correctly, and awhile after that but it seems to stop at some point.
example of my blade file calling my master
#extends('dashboard.master')
#section('content')
<p>This is my content</p>
#stop
Edit:
I tried removing everything and just pasting the HTML template I have. It still just stops rendering towards the end of the page. So all I have now is literally the master file and the includes in my blade template that calls the master.

Laravel will maintain a cache of views that have been accessed, just so that it doesn't have to compile the blade template for each page load. It should be refreshing a particular view should it change, but it sounds like, for some reason, the cache wasn't being refreshed.
You can clear the view cache in two different ways:
# Method 1
php artisan cache:clear
# Method 2
rm `ls /path/to/application/app/storage/views | grep -v '.gitignore'`
Reference

In order to show all page, change your last code to :
#extends('dashboard.master')
#section('content')
<p>This is my content</p>
#show

Related

Laravel 4 displays php tags (#extends) on web page as a string

I'm new to Laravel and I've just started my first project using WAMP, however, the special php tags, (#section, #extends, #stop), and all the other tags are displayed as a string.
I've switched Laravel's error variable to true and it still comes up as a string. I've checked Laravel's welcome.blade in my browser and although the html and css are working fine it displays the # tags. I've also tested the server by including and that works fine. I've checked everywhere online and there's no answers to this problem.
Here's an example:
#extends('layout')
#section('content')
Users!
#stop
This displays:
#extends('layout') #section('content') Users!
Any help please?
If you have blade file in a folder you need to add a folder name in extends
#extends('folder_name.layout')

Laravel view not rendering correctly

I am trying to add a new view to my laravel project, and it is just dumping the entire content on the page, including my blade code, instead of executing said code. For example, my page in the browser is this:
#extends('user.layouts.app') #section('title', 'New Reminder') #section('content')
New Reminder
#csrf
Title
Content
#endsection
When it should obviously be executing that code, not putting it on the page.
I have tried clearing the routes, and researched around but no dice.
I am calling this view the same way I am calling others in my code - in the controller like this:
return view('user.partials.stat_types.new_type');
Any help or advise is appreciated!
You must have the file name with the extension .blade.php if you want Blade to be used to compile the view. With just .php the PHP engine is used.
Change your view filename to have the .blade.php extension.

Laravel Blade : Not all properties go through to certain mini-views using #yield

I am working with Laravel and created a master.blade view file to use on all my pages.
The master view yields mini-views inside.
On most mini-views everything works fine, but on some, I don't get the background image from the master.
The problem is I still get the nav-bar and the footer on those pages, which means they do recognize the master view.
What can be the reason for that?
On all pages I use the exact same way to include and to yield:
#extends('master')
#section('content')
#endsection
Thanks alot!
Just use full path to your file, start with /

Laravel blade tem removes new line

It's not really a big problem, but it is mighty annoying.
When starting creating templates in laravel using blade, everything looks fine. The "master" template/layout gets it's "styling" correct. And by "styling" i mean like correct amount of whitespaces, newlines etc when viewing the source code.
The problem occurs when you know try to extend this master template.
for every #section('<something>') you do know, all newlines is removed from the code, making the source code look fuggly.
Have been searching this phenomenon for a while without finding anything interesting which explains why or maybe a solution to make the source code readable again.
Here is an example if the explanation wasn't good enough:
// master.blade.php
<html>
<head>
<title>Something here</title>
</head>
<body>
#yield('content')
</body>
</html
Alright, this will look exactly like this in the source code. Let's make a another template which extends this.
// home.blade.php
#extends('master')
#section('content')
<h1>Welcome</h1>
<p>This is my homepage</p>
#endsection
This will first of inherit the parent, and replace #yield('content') with:
<h1>Welcome</h1> <p>This is my homepage</p>
Is there any explanation at all why this happens?
For longer sub-templates reading the source code is a living hell. Best way to see the "source code" is to see the generated one in inspect element, which also is just the live code, and not the first generated.
- Sligthly annoyed developer
I believe this is up to Laravels way of handling views. Every blade-view you create in resources/views will be "translated" to PHP. This line in your code for example:
#yield('content')
will be translated to
<?php echo $__env->yieldContent('content'); ?>
you can easely check for yourself by checking all files at storage/framework/views/. This are the files Laravel will include to build the "real" HTML website. Note, that all tab-stops made in .blade.php views are replaced with 4 spaces. And there are this ugly intendations.

Laravel #extends failing to pull in master layout

While creating a basic item detail page for a basic blog I've run into a problem with Laravel's #extends not working when pulling in a master layout template. The content from the detail page loads just fine but the master page HTML is not there at all and I'm not getting any errors.
In my routes:
Route::get('blog', 'BlogController#public_index');
Route::get('blog/{id}', 'BlogController#public_single');
In my BlogController:
public function public_single($id) {
$blog = Blog::find($id);
return View::make('public.blog_single') -> with('blog', $blog);
}
At the very top of the blog_single template:
#extends('layouts.public')
All other templates that use this master layout work as expected.
My views directory structure:
views
|
|layouts
| |
| | admin.blade.php
| | public.blade.php
|
|public
|
|blog.blade.php
|blog_single.blade.php
One thing I'm wondering is if the fact that this page looks like it's rendering from a subdirectory is an issue. Here is an example:
This works:
www.mydomain.com/blog
This doesn't:
www.mydomain.com/blog/1
I've looked through the Laravel docs and don't see an answer there. Any ideas? Thanks.
Have you tried to add an absolute path to the master style references?
For example:
<link rel="stylesheet" href="css/bootstrap.min.css">
Has to be:
<link rel="stylesheet" href="/css/bootstrap.min.css">
In all the url's we use. This worked for me :)
Okay, not sure how this fixed it, hopefully someone can give me a little detail.
I found this line of code at the bottom of the blog_single.blade.php file:
<div class="text-center">{{ $blogs->links() }}</p>
That is leftover from a copy/paste of the blog.blade.php file and obviously on a detail page I don't need pagination.
I removed that one line of code and now the templates work as they should. Wondering why Laravel did not throw some sort of error if it was choking on that line, or why that line would effect the whole master file from getting included in the first place.
Anyway, it's fixed.

Categories