Created
October 4, 2013 08:21
-
-
Save boyhagemann/6822661 to your computer and use it in GitHub Desktop.
Quickly add a menu to your application, based on the first part of your routes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- Basic Page Needs | |
================================================== --> | |
<meta charset="utf-8" /> | |
<title>Default</title> | |
<meta name="keywords" content="your, awesome, keywords, here" /> | |
<meta name="author" content="Jon Doe" /> | |
<meta name="description" content="Lorem ipsum dolor sit amet, nihil fabulas et sea, nam posse menandri scripserit no, mei." /> | |
<!-- Mobile Specific Metas | |
================================================== --> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- CSS | |
================================================== --> | |
<link href="{{{ URL::asset('css/bootstrap.min.css') }}}" rel="stylesheet"> | |
<!-- HTML5 shim, for IE6-8 support of HTML5 elements --> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<!-- Favicons | |
================================================== --> | |
</head> | |
<body> | |
<nav class="navbar navbar-inverse navbar-static-top" role="navigation"> | |
<ul class="nav navbar-nav"> | |
@foreach($menu as $link => $label) | |
<li><a href="{{ $link }}">{{ $label }}</a></li> | |
@endforeach | |
</ul> | |
</nav> | |
<!-- Container --> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-lg-9">{{ $content }}</div> | |
</div> | |
</div> | |
<!-- ./ container --> | |
<!-- Javascripts | |
================================================== --> | |
</body> | |
</html> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View::composer('*', function($view) { | |
$menu = array(); | |
foreach(Route::getRoutes() as $existing) { | |
$path = $existing->getPath(); | |
$base = substr($path, 0, strpos($path, '/', 1)); | |
$menu[Config::get('app.url') . $base] = ucfirst(trim($base, '/')); | |
} | |
View::share('menu', $menu); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment