The following thinkphp framework tutorial column will introduce to you how to highlight the current page in thinkphp navigation. I hope it will be helpful to friends in need!
Applicable to tp5, it can solve the problem of secondary menu navigation highlighting, that is, obtain the current controller name and method name in the template, and look at the navigation bar clicked Whether it corresponds or not, the example is as follows:
<li class="{eq name=':request()->controller()' value='userinfo'}active{/eq}"> <a href="index.html#"><i class="icon-group"></i> <span class="nav-label">用户管理</span><span class="fa arrow"></span></a> <ul class="nav nav-second-level"> <li class="{eq name=':request()->action()' value='ueraddcheck'}active{/eq}"><a href="{:url('Userinfo/uerAddCheck')}">新增用户审核</a></li> <li class="{eq name=':request()->action()' value='edituser'}active{/eq}"><a href="{:url('Userinfo/editUser')}">编辑用户</a></li> </ul> </li>
{eq name=':request()->controller()' value='userinfo'} in the first-level menu is to determine which controller is passed If it corresponds to it, the class is active. The secondary menu {eq name=':request()->action()' value='ueraddcheck'} determines which method it comes from. If it corresponds to The active class is displayed.
The principle is the same for tp3, but the usage of getting the current controller name and method name is different. , examples are as follows:
<li class="menu-list <if condition='$Think.const.CONTROLLER_NAME eq Help'>active</if>"><a href="#"><i class="fa fa-tasks"></i> <span>帮助管理</span></a> <ul class="sub-menu-list"> <li class="<if condition='$Think.const.ACTION_NAME eq whoClaim'>active</if>"><a href="{:U('Help/whoClaim','','')}">谁认领了我</a></li> </ul> </li>
The above is the detailed content of About thinkphp navigation highlighting current page. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software