How to make a menu link display as active when the navigation is in a php include file
By Chris on March 29, 2011 in php
0
1
I always use this bit of code for my navigation links that are part of a php include file.
Whenever the recordset on the particular page (rs_page) is equal to the unique id from the row (in this case 1) it echoes “class=”selected”
<?php $pageon = $row_rs_page[‘page_id’]; $pagenumber = “1”; if ($pageon == $pagenumber) {echo ” class=\”selected\””;} ?>
… or another way would be to declare the name of each page using this at the top of your HTML (example ‘servicespage’) :
<?php $page_name = ‘servicespage’; ?>
and use this in your menu file:
<?php if($page_name == ‘servicespage’) echo ‘class=”selected”‘; ?>
0 Comments
Leave a reply
Leave a Reply
You must be logged in to post a comment.