I'm looking for a way to echo out the view name and place it in to the master template inside the body tag as a CSS Class.
The reason for this is I have some pages where certain CSS Elements need to change however inline code is inefficient and I don't really want to make a dedicated view for that one page.
So, for example, if I was to land on the home page the body tag would be:
<body class="home">
Where if I was to go to about the about us page, it would change to:
<body class="about">
Add to filters (or routes):
View::composer('*', function($view){
View::share('view_name', $view->getName());
});
You can then access the view name using $view_name
Try this:
<body class="@yield('class')">
And on your views
@section('class', 'Your boddy class')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With