I'm trying to use #parent to append li to ul to bulidbreadcrumb
this is my header code
(master.blade.php)
<ul class="breadcrumb">
#yield('breadcrumb')
</ul>
and this is my code in the view (index.blade.php)
#layout('layouts.default')
#section('breadcrumb')
<li> {{ HTML::link('','Brands') }} </li> #parent
#endsection
and this is the material i follow
http://laravel3.veliovgroup.com/docs/views/templating
#parent not work for me , i need help
thanks
You need to have #parent in your layouts.default so it echos the parent content.
http://laravel.com/docs/templates
#layout('layouts.default')
#section('breadcrumb')
#parent
<li> {{ HTML::link('','Brands') }} </li>
#endsection
#parent should be in a new line.
if you want that put #parent after, will work too.
#layout('layouts.default')
#section('breadcrumb')
<li> {{ HTML::link('','Brands') }} </li>
#parent
#endsection
I believe that #parent works in somewhere, but i tested only at begin and end.
#layout('layouts.default')
#section('breadcrumb')
<li> {{ HTML::link('','Brands') }} </li>
#parent
<li> {{ HTML::link('','Brands') }} </li>
#endsection
If you want, Laravel 4 brought many improvements to blade template.
Sorry my bad english. I tried write better.
Related
I am new to Laravel Nova ... I just installed optimistdigital/nova-menu-builder in order to generate menus in a more efficient way then whats generated by nova. My menu structure is very complex and needs more control. Anyway, I installed the package and created a menu. I am at the point where I would like to load it in the sidebar but can't figure out how that works ...
in the navigation.blade.php file I added:
#menu("admin")
Where admin is supposed to be the menu slug
After a refresh, nothing happened. So I tried something more basic. I removed the #menu and added "hello world" instead. It did not appear ... So I ran the following commands:
php artisan config:clear
php artisan cache:clear
php artisan nova:publish
All 3 were executed without any errors. But the sidebar still did not show my hello world.
So my question is the following. How can I reflect my changes in the blade views? And is #menu("") the right way to use the optimistdigital/nova-menu-builder package? The documentation seems to be missing the part on how to use the menus you create... Thx in advance!
Here's my layout page
<router-link exact tag="h3"
:to="{
name: 'dashboard.custom',
params: {
name: 'main'
}
}"
class="cursor-pointer flex items-center font-normal dim text-white mb-8 text-base no-underline">
<svg>[Long SVG string]</svg>
<span class="text-white sidebar-label">{{ __('Dashboard') }}</span>
</router-link>
hello world
#menu("admin")
#if (\Laravel\Nova\Nova::availableDashboards(request()))
<ul class="list-reset mb-8">
#foreach (\Laravel\Nova\Nova::availableDashboards(request()) as $dashboard)
<li class="leading-wide mb-4 ml-8 text-sm">
<router-link :to='{
name: "dashboard.custom",
params: {
name: "{{ $dashboard::uriKey() }}",
},
query: #json($dashboard->meta()),
}'
exact
class="text-white no-underline dim">
{{ $dashboard::label() }}
</router-link>
</li>
#endforeach
</ul>
#endif
Thx to leek, I was able to find how to retrieve the menus and build on that.
So my first problem was that I was editing the wrong file. You need to do the following first:
copy the file in nova/resources/views/layout.blade.php and put it in
/resources/views/vendor/nova.
After doing this your changes will reflect correctly. I moved all the files in the nova view folder while I was at it.
In side the newly created /resources/views/vendor/nova/layout.blade.php file replace this code:
#foreach (\Laravel\Nova\Nova::availableTools(request()) as $tool)
{!! $tool->renderNavigation() !!}
#endforeach
with this code:
#php
$menus = [
nova_get_menu('admin'),
];
#endphp
<section style="width: 100%; position: absolute; top: 60px;">
<ul class="sidebar-menu">
<li class="sidebar-header">MAIN NAVIGATION</li>
<li>
<a href="/nova">
<i class="fa fa-dashboard"></i> <span>Dashboard</span></i>
</a>
</li>
#foreach ($menus as $menu)
#continue(is_null($menu))
<li>
<a href="">
<i class="fa fa-dashboard"></i> <span>{{ $menu['name'] }}</span> #if ($menu['menuItems'])<i class="fa fa-angle-left pull-right"></i> #endif
</a>
#if ($menu['menuItems'])
<ul class="sidebar-submenu">
#foreach (($menu['menuItems'] ?? []) as $item)
<li>
#if ($item['type'] === 'text')
{{ $item['name'] }}
#else
<a href="{{ $item['value'] }}"
target="{{ $item['target'] }}"
#if ($item['target'] === '_blank') rel="noopener" #endif><i class="fa fa-circle-o"></i> {{ $item['name'] }}</a>
#endif
</li>
#endforeach
</ul>
#endif
</li>
#endforeach
<li>
<a href="/nova/logout">
<i class="fa fa-sign-out"></i> <span>Logout</span></i>
</a>
</li>
</ul>
</section>
Replace "admin" with the slug of your menu
You can change the HTML to what ever you want.
I used https://www.jqueryscript.net/menu/Stylish-Multi-level-Sidebar-Menu-Plugin-With-jQuery-sidebar-menu-js.html
And the result is:
You can add more then one menu like this if you need to
#php
$menus = [
nova_get_menu('admin'),
nova_get_menu('user'),
nova_get_menu('pages'),
nova_get_menu('configuration'),
nova_get_menu('store'),
];
#endphp
The foreach loop will add them all to your page in the order you put them in the $menus array.
Good luck!
Quote from this issue on GitHub:
[nova_get_menu()] only returns a PHP array. You have to handle creating the HTML yourself.
As of version 2.3.7, you will need to use this function yourself to generate your own menu HTML:
$menuJson = nova_get_menu('admin')
// Returns:
// [
// 'id',
// 'name',
// 'slug',
// 'locale',
// 'menuItems' => []
// ]
I am having a curious blade problem.
I have an edit blade that is rendering, but not with the master blade. Debugbar shows that both views (master and delete) are being shown. They are not!
Other blades used in conjunction with master all work. I tried duplicating those blades and inserting the specific data to no avail.
I have cleared history in the browser and done php artisan cache:clear. Nothing.
Master Blade is working for all other renderings. Here is detail:
<div class="intro">
<section>
#yield('intro')
</section>
</div>
This blade works and is rendered with the master:
#extends('layouts.master')
#section('title')
Your Profile
#stop
#section('head')
#stop
#section('intro')
<div class="output">
<h2>Your Pets</h2>
<div>
</div>
#if(sizeof($pets) == 0)
No pets
#else
#foreach($pets as $pet)
<div class="p1">
<h3>{{ $pet->petName }}</h3>
<p><img src='{{ $pet->photo }}' width="200px" height="200px"></p>
<p>{{ $pet->breed }}</p>
<a href='/profile/edit/{{$pet->id}}'>Edit</a> |
<a href='/profile/confirm-delete/{{$pet->id}}'>Delete</a>
</div>
#endforeach
#endif
</div>
#stop
#section('body')
#stop
This blade renders but with no master! Debugbar says that both views are rendering. Ha!
#extends('layouts.master')
#section('title')
Delete Your Pet
#stop
#section('head')
#stop
#section('intro')
<div class="output">
<h1>Delete Pet</h1>
<p>
Are you sure you want to delete <em>{{$pets->petName}}</em>?
</p>
<p>
<a href='/profile/delete/{{$pets->id}}'>Yes...</a>
</p>
</div>
#stop
#section('body')
#stop
Anyone seen this?
#stop was removed from the docs as of 5.1, so I would guess it is probably no longer supported. Use #endsection instead.
http://laravel.com/docs/5.1/blade
I'm building a website with Volt 0.9 and I'm trying to customize my main.html regarding navigation.
Well, there is and if binding in the :Nav section to add a class. The problem is that I want to add another class with another if binding. I've tried to add a second if binding, but no luck, the are not rendered when I'm using a second if binding.
How can I do that ?
Here's the file :
<:Title>
{{ view main_path, "title", {controller_group: 'main'} }}
<:Body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<ul class="nav navbar-nav pull-left">
<:nav href="/">Hammicus</:nav>
<:nav href="/tv">HammicusTV</:nav>
<:nav href="/radio">HammicusRadio</:nav>
<:nav href="/contact">Contact</:nav>
</ul>
<:volt:notices />
{{ view main_path, 'body', {controller_group: 'main'} }}
</div>
</nav>
<footer class="footer">
<p>© Hammicus {{ Time.now.year }}</p>
</footer>
<:Nav>
<li class="{{ if active_tab? }}active{{ end }} {{ if attrs.href == "/" }}brand{{ end }}">
{{ yield }}
</li>
The problem seems to be the double quotes around the "/"
Replace them with single quotes (so they are properly nested) and it should work.
ie
class="{{ if active_tab? }}active{{ end }} {{ if attrs.href == '/' }}brand{{ end }}"
How to format Laravel Link with <li> and <span> tags, for an example:
Laravel Link
{{ link_to('home', 'Home') }}
Should have to set like this
<li>
<a href="home">
<i class="icon-text-width"></i>
<span class="menu-text"> Home </span>
</a>
</li>
can someone please help me to create Laravel base link with that html tags, thank you
As far as i know, you can not do that using {{ link_to('home', 'Home') }}. However, instead you can do something like the following:
<li>
<a href="{{ route('home') }}">
<i class="icon-text-width"></i>
<span class="menu-text"> Home </span>
</a>
</li>
or you can use url() helper function.
<li>
<a href="{{ url('/') }}">
<i class="icon-text-width"></i>
<span class="menu-text"> Home </span>
</a>
</li>
I have a Markdown page index2.md as follow:
---
layout: plain
title: Index2
---
test Index2
<ul class="posts">
{% for post in site.posts %}
<li><span>{{ post.date | date_to_string }}</span> » {{ post.title }}</li>
{% endfor %}
</ul>
However this can't show my blog posts
<body>
<div class="wrapper">
<header>
<h1>Nodeclipse.github.io</h1>
<p>Resource for Nodeclipse developers</p>
<p class="view">View My GitHub Profile</p>
</header>
<section>
<div>
<p>test Index2</p>
<p> <ul class="posts"></p>
<p> </ul></p>
</div>
</section>
<footer>
<p><small>Hosted on GitHub Pages — Theme by orderedlist</small></p>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
</body>
That is blog list is empty.
Markdown is interpreting your indented HTML as content, and helpfully wrapping it in a <p> tag for you.
Markdown will pass HTML through raw, which is what you want, but only if the starting and ending tags are not indented at all. So, un-indent the opening and closing <ul> and </ul> tags, and Markdown will let the entire chunk of HTML go unmolested. So it should look like this:
test Index2
<ul class="posts">
{% for post in site.posts %}
<li>
<span>{{ post.date | date_to_string }}</span>
»
{{ post.title }}
</li>
{% endfor %}
</ul>