php - Current page hightlight button -
i have 3 buttons in header php file of site. want change color of button when on page cannot working correctly trying use $thispage statement call if on 1 of pages adds id="currentpage." here code using
<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 how want */ }
Comments
Post a Comment