Home PHP Framework ThinkPHP About thinkphp navigation highlighting current page

About thinkphp navigation highlighting current page

Dec 23, 2020 pm 03:02 PM

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!

About thinkphp navigation highlighting current page

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=&#39;:request()->controller()&#39; value=&#39;userinfo&#39;}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=&#39;:request()->action()&#39; value=&#39;ueraddcheck&#39;}active{/eq}"><a href="{:url(&#39;Userinfo/uerAddCheck&#39;)}">新增用户审核</a></li>
         <li class="{eq name=&#39;:request()->action()&#39; value=&#39;edituser&#39;}active{/eq}"><a href="{:url(&#39;Userinfo/editUser&#39;)}">编辑用户</a></li>
      </ul>
 </li>
Copy after login

{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=&#39;$Think.const.CONTROLLER_NAME eq Help&#39;>active</if>"><a href="#"><i class="fa fa-tasks"></i> <span>帮助管理</span></a>
    <ul class="sub-menu-list">
       <li class="<if condition=&#39;$Think.const.ACTION_NAME eq whoClaim&#39;>active</if>"><a href="{:U(&#39;Help/whoClaim&#39;,&#39;&#39;,&#39;&#39;)}">谁认领了我</a></li>
    </ul>
</li>
Copy after login

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)