jeremiah11 Posted August 12, 2008 Posted August 12, 2008 Hello, I am trying to make selected tabs (text styled through css to look like tabs) to be shown as a different colour when the page is current. I know how to do this by implementing different header.php files but i am trying to use if statements by giving each an ID. I do not know where to put the ID when my links are used as filenames. Eg. <?php $id=$_GET["id"]; if($id=="Home") { ?> <div class="nav-item first selected" id="nav-item-home"> <a href="<?php echo tep_href_link(FILENAME_DEFAULT, ''); ?>" class="content">Products</a> //Where do i put id=home?????? </div> <?php } else { ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_DEFAULT, ''); ?>" class="content">Products</a> </div> </div> <?php } ?> Thanks for your help ahead of time :blush:
Guest Posted August 12, 2008 Posted August 12, 2008 <a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'id=Home'); ?>" class="content">Products</a>
jeremiah11 Posted August 12, 2008 Author Posted August 12, 2008 <a href="<?php echo tep_href_link(FILENAME_DEFAULT, 'id=Home'); ?>" class="content">Products</a> That seemed to not work. The link just stayed the same instead of giving the current tab color. I have seen it work when i had seperate header.php files so i know he code is working....i just don't know where to exactly put the id=Home. Any other ideas?
jeremiah11 Posted August 12, 2008 Author Posted August 12, 2008 did you do it for both of the links? No, only for the first one.
jeremiah11 Posted August 12, 2008 Author Posted August 12, 2008 did you do it for both of the links? I put it in for both and it worked:) I still have a small problem though. When i hit the url instead of the link the new current colour for the link does not show up. Do you have any suggestions to what i should do to get that to work???
jeremiah11 Posted August 12, 2008 Author Posted August 12, 2008 did you do it for both of the links? Just to clarify when i click on the link on the page everything works great, but if i type in www.microsoft.com/index.php i am not getting the current link colour i want because the id is missing at the end of the URL. Thanks again for helping me out with this! Jeremiah
Guest Posted August 13, 2008 Posted August 13, 2008 I personally would approach it differently e.g. $id=basename($PHP_SELF); if($id == FILENAME_DEFAULT) { ?> <div class="nav-item first selected" id="nav-item-home"> <a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>" class="content">Products</a> </div> <?php } else { ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>" class="content">Products</a> </div> </div> <?php } ?> that way go don't need to add anything to the path
♥FWR Media Posted August 13, 2008 Posted August 13, 2008 I have a terrible feeling that I'm missing the plot (had a bottle of wine or three) .. but I'll have a bash .. I'm assuming (never a good idea ) that you may want all index.php pages to be non tabbed and certain other pages tabbed, for the purposes of this I'm using the usual culprits .. Conditions Contact_us Privacy Shipping $tab_file = basename($_SERVER['SCRIPT_NAME']); switch($tab_file){ case($tab_file == FILENAME_CONDITIONS): ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_CONDITIONS); ?>" class="content">Products</a> </div> </div> <?php break; case($tab_file == FILENAME_CONTACT_US): ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_CONTACT_US); ?>" class="content">Products</a> </div> </div> <?php break; case($tab_file == FILENAME_SHIPPING): ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_SHIPPING); ?>" class="content">Products</a> </div> </div> <?php break; case($tab_file == FILENAME_PRIVACY): ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link(FILENAME_PRIVACY); ?>" class="content">Products</a> </div> </div> <?php break; default: ?> <div class="nav-item first selected" id="nav-item-home"> <a href="<?php echo tep_href_link(FILENAME_DEFAULT); ?>" class="content">Products</a> </div> <?php break; } Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
♥FWR Media Posted August 13, 2008 Posted August 13, 2008 As I thought it doesn't make sense, I'm replacing only one tab (and I'm not sure I'm on the right track anyway) I'll still post again though .. well until I fall over. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
♥FWR Media Posted August 13, 2008 Posted August 13, 2008 Another version An array of files for which you wish to show tabs $tabsArray = array(FILENAME_DEFAULT, FILENAME_CONDITIONS, FILENAME_CONTACT_US, FILENAME_SHIPPING, FILENAME_PRIVACY); The function call to print the tags tabMeUpScotty($tabsArray); The function itself .. probably in includes/functions/general.php function tabMeUpScotty($tabsArray){ $tab_file = basename($_SERVER['SCRIPT_NAME']); foreach( $tabsArray as $value ){ $tabname = ucfirst(str_replace('.php', '', $value)); if( ($value == $tab_file) && ($tab_file != FILENAME_DEFAULT) ){ ?> <div class="nav-item"> <div class="nav-tab"> <a href="<?php echo tep_href_link($tab_file); ?>" class="content"><?php echo $tabname; ?></a> </div> </div> <?php } else { ?> <div class="nav-item first selected" id="nav-item-home"> <a href="<?php echo tep_href_link($value); ?>" class="content"><?php echo $tabname; ?></a> </div> <?php } } } Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.