Home > Backend Development > PHP Tutorial > Laravel 5.1 高亮菜单

Laravel 5.1 高亮菜单

WBOY
Release: 2016-06-23 13:25:43
Original
1083 people have browsed it

最近基于Laravel5.1做项目开发,后台菜单高亮,原来用jQuery做菜单高亮,但发现到了新方法里就不奏效了,还是在定义变量在View层判断即可。

基类

定义两个变量,并共享到所有模板里

class BaseController extends Controller{    public $module;    public $parent_module;    public function __construct()    {        View::share('active',[$this->module=>'active']);        View::share('parent_active',[$this->parent_module=>'active']);    }}
Copy after login

继承的类
(赋值变量)

class ShopCategoryTagController extends BaseController{    public $module = 'cate_tag';    public $parent_module = 'parent_shop';
Copy after login

视图层

父级

<li class="treeview {{isset($parent_active['parent_shop']) ? $parent_active['parent_shop'] : ''}}">
Copy after login

子级

<li class="{{isset($active['cate_tag']) ? $active['cate_tag'] : ''}}"><a href="{{url('admin/shop_category_tag')}}">
Copy after login

效果:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template