[英]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' : ''; ?>
我想在此行中添加``用户/配置文件''和``用户/设置''或更多网址。我如何仅使用此php行来做到这一点。
您可以尝试in_array
方法
<?php echo in_array(uri_string(), ['user/profile', 'user/setting']) ? 'm-submenu__item--active' : ''; ?>
Just use regex. 只需使用正则表达式即可。 You will be doing array on all possible 'user' routes?
您将在所有可能的“用户”路径上进行阵列处理吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.