当前页面高亮按钮


Current page hightlight button

我的站点的PHP头文件中有3个按钮。当你在该页面上时,我想更改按钮的颜色,但我无法使其正常工作,所以我试图使用$thispage语句来调用它,所以如果它在其中一个页面上,它会添加id="currentpage"

<input type='button' value='AVAILABLE NOW' onClick='location="/category/upcoming/"' <?php if ($thisPage) echo " id='"currentpage'""; ?> class="header-image" />
<input type='button' value='COMING SOON' onClick='location="/category/soon/"' <?php if ($thisPage) echo " id='"currentpage'""; ?>class="header-image" />
<input type='button' value='VAULT ARCHIVE' onClick='location="/category/previous/"' <?php if ($thisPage) echo " id='"currentpage'""; ?>class="header-image" />

PHP

<?php
$page_name = basename(__FILE__);
?>

HTML

 <li <?php echo ($page_name == 'page1.php' ? 'class="currentpage"' : 'class="h"'); ?>><a href="whatever.php"> Link1</a></li>
 <li <?php echo ($page_name == 'page2.php' ? 'class="currentpage"' : 'class="h"'); ?>><a href="whatever.php"> Page 2</a></li>

CSS

.currentpage{
/*Format it how you want it */
}