Within a Layout
#section('breadcrumbs', Breadcrumbs::render('messages'))
#section('content')
#include('layouts.breadcrumbs')
breadcrumbs.blade.php
<div class="fluid-container">
<div class="container">
<div class="row">
<div class="col-md-12">
#yield('breadcrumbs')
</div>
</div>
</div>
</div>
Standard BS3 view with DaveJamesMillar Breadcrumbs
#if ($breadcrumbs)
<ol class="breadcrumb">
#foreach ($breadcrumbs as $breadcrumb)
#if ($breadcrumb->url && !$breadcrumb->last)
<li>{{ $breadcrumb->title }}</li>
#else
<li class="active">{{ $breadcrumb->title }}</li>
#endif
#endforeach
</ol>
#endif
Appeared to be working fine until upgrading to L5.4, now rather than displaying the breadcrumbs it displays non-processed HTML
<ol class="breadcrumb"> <li>Home</li> <li> class="active">Messages</li></ol>
After reading the latest docs for davejamesmillar laravel-breadcrumbs with support for L5.4 https://media.readthedocs.org/pdf/laravel-breadcrumbs/latest/laravel-breadcrumbs.pdf with reference to 1.4.2 using Blade Sections nothing appears to have changed in the way this needs to be coded. Unsure why the HTML is not being processed to display as a link.
RAR, hours later! Appears Laravel 5.4 runs a htmlentities when injecting a variable into a #section
I changed
#section('breadcrumbs', Breadcrumbs::render('messages'))
to
#section('breadcrumbs') {!! Breadcrumbs::Render('messages') !!} #endsection
And the html is now being processed and displayed as it should.
Related
I am doing a validation of a form in Laravel.
In this form I have two inputs (one text and one checkbox).
But I have two lists, in which I can move the elements from one list to another and order them.
But I don't know how to send these lists through the form to the Laravel validation.
Thanks in advance
My form:
<form id="create-menu-opac" action="{{ route('post_create_menu_opac')}}" method="post" role="form" autocomplete="off">
{{ csrf_field() }}
...
<section>
<div class="row">
<div class="col-sm-6">
<h6>{{ trans('menu-opac.buttons_avaiable') }}</h6>
<ul id="buttons_no_selected" class="list-group list-group-sortable-connected connected">
#foreach ($buttons as $button)
<li id="{{$button->id}}" class="list-group-item list-group-item-info">{{$button->description}}</li>
#endforeach
</ul>
</div>
<div class="col-sm-6">
<h6>{{ trans('menu-opac.items_menu') }}</h6>
<ul id="buttons_selected" class="list-group list-group-sortable-connected connected">
</ul>
</div>
</div>
</section>
...
</form>
This two lists work with a library Jquery and Boostrap
My controller
foreach ($request as $_request) {
Log::Debug(print_r($_request,true));
}
In this Log I can see the two inputs (type text and type checkbox), but i can't see the list.
Try adding input hidden in your blade file then see if you get the data in your $request
#foreach ($buttons as $button)
<li id="{{$button->id}}" class="list-group-item list-group-item-info">{{$button->description}}</li>
<input type="hidden" id="{{$button->id}}" value="{{$button->description}}" name="{{$button->description}}">
#endforeach
I have a symfony page composed of 3 parts ( and i'm using tags to display each part) by navigation menu here is the navigation menu.
<ul class="nav nav-tabs centered">
<li class="active">
{{ 'fiche_pharmacie'|trans }}
</li>
<li>
{{ 'Mon équipe'|trans }}
</li>
<li>
{{ 'Configuration_automate'|trans }}
</li>
{# <li>
{{ 'Services'|trans }}
</li> #}
</ul>
After that i call 3 twig pages to display each page content.
<div class="tab-pane" id="fiche_patient">
{{ include(':prof/Entreprise:indexdetails.html.twig') }}
</div>
<div class="tab-pane" id="my_team2">
{{ include(':prof/Entreprise:my-team.html.twig') }}
</div>
<div class="tab-pane" id="config">
{{ include(':prof/Entreprise:config.html.twig') }}
</div>
My probleme is after submit i would like to display config.html.twig page.
In my controler i tried :
return $this->redirect($this-> generateUrl('entreprise_index'.'#config'));
but it doesn't work
Any one of you have an idea ?
The correct syntax for what you are trying to do there is:
return $this->redirect($this->generateUrl('entreprise_index').'#config');
You can use redirectToRoute()
$yourRouteParams = array('param1'=>1);
return $this->redirectToRoute('entreprise_index', $yourRouteParams);
You can send the tab name as a parameter to twig. And, in the template, set the active tab according to that parameter.
How do I include snippets, or partials in pages in Laravel 5? In node/angular, it's quite easy to simply load different modules and such on a page.
For example, on my home page, I'm looping through some data:
<h1>Home</h1>
#if (count($practice))
<ul>
#foreach($practice as $val)
<li>{{ $val }}</li>
#endforeach
</ul>
#endif
If I include the login snippet on the page, it covers up the rest of the data:
<h1>Home</h1>
#if (count($practice))
<ul>
#foreach($practice as $val)
<li>{{ $val }}</li>
#endforeach
</ul>
#endif
#include('auth.login')
Try to include it in a new row :
<h1>Home</h1>
#if (count($practice))
<div class="row">
<div class="col-md-12">
<ul>
#foreach($practice as $val)
<li>{{ $val }}</li>
#endforeach
</ul>
</div>
</div>
#endif
<div class="row">
<div class="col-md-12">
#include('auth.login')
</div>
</div>
I was working on my website and I logged out to test it and it gave me this error:
Trying to get property of non-object (View: C:\xampp\htdocs\mom\a\app\views\home.blade.php)
Here is my home.blade.php:
#extends('layout.main')
#section('title') Home #stop
#section('content')
<!-- User signed in -->
#if(Auth::check())
<!-- User is not admin -->
<p>Welcome back, {{ Auth::user()->username }}.</p>
#else
<!-- Nothing -->
#endif
#if($posts->count())
#foreach($posts as $post)
<article class="col-md-8 col-md-push-2 well well-white home-posts">
<h2 class="title">{{ $post->title }}</h2>
<hr class="post-break">
<h4 class="home-content">{{ Markdown::parse(Str::limit($post->body, 300)) }}</h4>
<div class="post-footer">
<ul class="footer-group">
<ul>
<li>Published {{ $post->created_at->diffForHumans() }}</li>
<li> Read more →</li>
</ul>
#if(Auth::user()->group ==1)
<ul class="footer-right">
<li class="red"><i class="fa fa-trash"></i> Delete</li>
<li><i class="fa fa-gear"></i> Edit</li>
</ul>
#else
<!-- Nothing -->
#endif
</ul>
</div>
</article>
#endforeach
#endif
<div class="col-md-8 col-md-push-2 ">{{ $posts->appends(array())->links() }}</div>
#stop
If someone could help me find out what property is of the non object is being called and help me fix it. That would be great. Much appreciated.
You should put this line
<div class="col-md-8 col-md-push-2 ">{{ $posts->appends(array())->links() }}</div>
in your if statement
EDIT:
Try to change line:
#if(Auth::user()->group ==1)
to
#if(Auth::check() && Auth::user()->group ==1)
I have breadcrumbs in my master.blade.php file and i want the breadcrumbs to be used everywhere BUT the homepage.blade.php.
right now this is how i add links to the breadcrumbs in other pages like "About".
about.blade.php:
#section('breadcrumbs')
#parent
<li class="last-breadcrumb">
About
</li>
#stop
in the master.blade.php:
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
but i don't want the breadcrumbs code to display at all when homepage.blade been used.
copying the code for each about.blade/X.blade files seems like a bad idea..
Your can set a value in your controller that you pass with the make/redirect like $data['breadcrumb'] = true and wrap your breadcrumb code in an conditional. This kind of system also works well for error and success messages since you can alse send content from your controller. Then you would send an array with values instead of true.
Blade template
<div class="container">
#if($breadcrumb)
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
#endif
</div>
You can check the URI to see if you want to display it or not. It's logic in your view which is usually frowned upon, but it's the easiest way I can come up with.
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#if(Route::uri() == '/')
<li class="last-breadcrumb">
About
</li>
#endif
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
Depending on the URI you are using for your home page, you may need to tweak the condition.
If you use #yield in your master template then it will only display content when the section has been defined. #content requires the section to be always defined.