Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the current view name inside a master layour in Laravel 4?

Tags:

php

laravel-4

in Laravel 4 I have a master blade layout and I want to add a class to the html element like 'tpl-home', but I need to know which is the current view name called with View::make.

<!doctype html>
<html lang="es" class="tpl-{{Str::slug($currentViewName)}}">

Does Laravel provide any function for retrieving this?

Thanks

like image 994
itsjavi Avatar asked Dec 02 '22 20:12

itsjavi


1 Answers

Inside your filters file place:

View::composer('*', function($view){

    View::share('view_name', $view->getName());

});

Then in your master blade layout you can access it as $view_name.

like image 57
tliokos Avatar answered May 06 '23 02:05

tliokos