php - Pass variable to all views created in a Laravel Controller -
i'm organizing website in sections, should visible @ first glance on navigation bar (with active
class on appropriate link). @ moment, i'm checking each link in navbar if current url matches 1 link, it's working 1 url in each case. should :
article
----------------> article
section article/create
-----> article
section article/edit
--------> article
section forum
-------------------> forum
section forum/post/12345
-> forum
section since "sections" utilize controllers, thinking maybe implement way (maybe using constructor) pass variable (section
) views returned controller, layout can have access , set active
class on proper link.
but don't want have return view::make('myview')->with('section', $this->section);
everytime
anyone knows how accomplish ? thanks.
you should utilize request::segment(1)
compare section.
if url article/create
, utilize request::segment(1)
homecoming article
, not article/create
and in fact, don't have pass blade in case, because should visible:
@if (request::segment(1) == 'article') class="active" @endif
php laravel laravel-4 blade
No comments:
Post a Comment