Guest jamble Posted April 9, 2008 Share Posted April 9, 2008 Does anyone know how I might be able to highlight the current category link in the category navigation? Basically to show the visitor that they're in a specific section of the site. All I get at the moment is the normal: <ul id="mainmenu-nav"> <li class="li-nav"> <a href="http://localhost/icediamond/www/cubecart/index.php">Homepage</a> </li> <li class="li-nav"> <a href="http://localhost/icediamond/www/cubecart/engagement-rings/cat_2.html">Engagement Rings</a> </li> <li class="li-nav"> <a href="http://localhost/icediamond/www/cubecart/wedding-bands/cat_3.html">Wedding Bands</a> </li> </ul> I'd like to be able to assign an id to the link so I can style it to show it's different to the other links based on where people are but I can't really see how I'd do this. (like this - on the last list item) <ul id="mainmenu-nav"> <li class="li-nav"> <a href="http://localhost/icediamond/www/cubecart/index.php">Homepage</a> </li> <li class="li-nav"> <a href="http://localhost/icediamond/www/cubecart/engagement-rings/cat_2.html">Engagement Rings</a> </li> <li class="li-nav" id="current"> <a href="http://localhost/icediamond/www/cubecart/wedding-bands/cat_3.html">Wedding Bands</a> </li> </ul> Many thanks, Sorry for the bump, I figured someone might be able to help but no suggestions? Quote Link to comment Share on other sites More sharing options...
Guest Brivtech Posted April 15, 2008 Share Posted April 15, 2008 In categories.inc.php, when building the categories list that's being assigned to the template, you'll need to create a condition to check if the current category matches the one being fetched from the database, and if so, assign a {variable} with 'id="current"', or empty ('') if not, and use that variable in the template file in place of the code. If the current category is met, your ID is used, otherwise, it leaves it out. Quote Link to comment Share on other sites More sharing options...
Guest Open Interactive Posted May 7, 2008 Share Posted May 7, 2008 In categories.inc.php, when building the categories list that's being assigned to the template, you'll need to create a condition to check if the current category matches the one being fetched from the database, and if so, assign a {variable} with 'id="current"', or empty ('') if not, and use that variable in the template file in place of the code. If the current category is met, your ID is used, otherwise, it leaves it out. Im looking to the exact same thing. any hints on what the syntax to accomplish this might look like? im not very advanced with PHP but it looks like this is the area that needs to be altered: if (is_array($treeData)) { for ($i=0; $i<count($treeData); $i++) { // Useful info to debug with //echo $treeData[$i]['cat_name'].", cat_id=".$treeData[$i]['cat_id'] .", noProducts=".$treeData[$i]['noProducts'] .", cat_father_id=".$treeData[$i]['cat_father_id'] .", level=". $treeData[$i]['level']."<hr>"; $upperlevel = (!isset($treeData[$i+1]['level'])) ? 1 : $upperlevel = $treeData[$i+1]['level']; if ($treeData[$i]['level'] > $upperlevel) { for ($n=0; $n<($treeData[$i]['level']-$upperlevel); $n++){ $box_content->parse('categories.a.ul_end'); } $box_content->parse('categories.a.li_end'); } else if ($treeData[$i]['level'] == $upperlevel) { $box_content->parse('categories.a.li_end'); } $box_content->parse('categories.a.li_start'); $box_content->assign('DATA', $treeData[$i]); $box_content->parse('categories.a'); if ($treeData[$i]['level']<$treeData[$i+1]['level']) { $box_content->parse('categories.a.ul_start'); } } } anyones help greatly appreciated Quote Link to comment Share on other sites More sharing options...
Homar Posted May 7, 2008 Share Posted May 7, 2008 In categories.inc.php, when building the categories list that's being assigned to the template, you'll need to create a condition to check if the current category matches the one being fetched from the database, and if so, assign a {variable} with 'id="current"', or empty ('') if not, and use that variable in the template file in place of the code. If the current category is met, your ID is used, otherwise, it leaves it out. It may be more complicated than this if you want the category highlighted when you are viewing a product within that category. Your best bet is to go over to cubecartforums.org. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.