如何为 php 的子菜单添加两个或更多 url 到活动 class?
how to add two or more urls to active class for sub menu with php?
<?php echo (uri_string() == 'user/profile') ? 'm-submenu__item--active' : ''; ?>
我想添加 'user/profile' 和 'user/setting' 或更多 url 到这个 line.How 我可以只使用这个 php 行吗?
你可以试试in_array
方法
<?php echo in_array(uri_string(), ['user/profile', 'user/setting']) ? 'm-submenu__item--active' : ''; ?>
只需使用正则表达式。您将在所有可能的 'user' 路线上进行排列?
<?php echo (uri_string() == 'user/profile') ? 'm-submenu__item--active' : ''; ?>
我想添加 'user/profile' 和 'user/setting' 或更多 url 到这个 line.How 我可以只使用这个 php 行吗?
你可以试试in_array
方法
<?php echo in_array(uri_string(), ['user/profile', 'user/setting']) ? 'm-submenu__item--active' : ''; ?>
只需使用正则表达式。您将在所有可能的 'user' 路线上进行排列?