Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Changing Font Color of Single Category Link

Changing Font Color of Single Category Link

Locked

Views: 2,471

Results 1 to 20 of 26
This thread is locked. New replies are disabled.
25 Apr 2010, 3:00 AM
#1
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Changing Font Color of Single Category Link

Is there anyway to change the font color for a single category link? I only need to change the "Sale" link located in the top horizontal menu to red and leave the remaining font color black.

Link to my site is http://tregreekboutique.com/zencart/.

25 Apr 2010, 8:07 AM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

It looks like you have a category that is called 'Sale' rather than using the specials page. So...

find a file called:

includes/modules/yourtemplate/category_tabs.php

(Or create it as an override if it does not already exist)

Near the bottom find the line :

 // create link to top level category

And insert directly above it to get:

if ($categories_tab->fields['categories']=='Sale'){
  $new_style .=  ' red_menu';
}

  // create link to top level category

That should add a new class, red_menu, to the category called 'Sale'. You will want to add a style to your stylesheet that looks something like:

.red_menu{
color:red !important;
}
25 Apr 2010, 10:59 PM
#3
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

Thanks for the code suggestion. I added the code to categories_tabs.php and stylesheet, but the font color did not change.

I have installed the add-on for the horizontal drop down menu for the categories, so I wasn't sure if that would be the reason why the code would not work.

http://www.tregreekboutique.com/zencart

Any other suggestions?

26 Apr 2010, 7:00 AM
#4
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

Ooops. Sorry I made a typo. Where it says fields['categories'] it should say fields['categories_name']

So the whole thing is :

if ($categories_tab->fields['categories_name']=='Sale'){
  $new_style .=  ' red_menu';
}


  // create link to top level category

Definitely works on the default install ( I have just tried it ) and I can't see that it wouldn't work on your cart but if it does not then just zip your version of this file and attach it to a post.

26 Apr 2010, 3:30 PM
#5
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

I made the code change and the font color still did not change. :(

I'm attaching a copy of the categories_tabs.php file.

Thanks again for your help on this.

http://www.tregreekboutique.com/zencart

<?php
/**
 * categories_tabs.php module
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: categories_tabs.php 3018 2006-02-12 21:04:04Z wilt $ */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access'); }
$order_by = " order by c.sort_order, cd.categories_name ";
$categories_tab_query = "select c.categories_id, cd.categories_name from " .
TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
             where c.categories_id=cd.categories_id and c.parent_id= '0' and cd.language_id='" . (int)$_SESSION['languages_id'] . "' and c.categories_status='1'" .
$order_by;      $categories_tab = $db->Execute($categories_tab_query);
$links_list = array();
while (!$categories_tab->EOF) {
  // currently selected category
  if ((int)$cPath == $categories_tab->fields['categories_id']) {
 $new_style = 'category-top';
 $categories_tab_current = '<span class="category-subs-selected">' . $categories_tab->fields['categories_name'] . '</span>';  } else 
{  $new_style = 'category-top';
    $categories_tab_current = $categories_tab->fields['categories_name']; }
  //added code to make "Sale" link font color RED
if ($categories_tab->fields['categories_name']=='Sale'){
  $new_style .=  ' red_menu'; }
  // create link to top level category
  $links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> ';
  $categories_tab->MoveNext(); }
?>
26 Apr 2010, 10:51 PM
#6
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

There are two reasons this might be happening

  1. You don't have a category called 'Sale'. You seem to though. Just confirm that you do.

  2. You are perhaps editing the wrong file. Just to check we are going to make a temporary edit in the file that will be ugly!

At the bottom of the file there is this;

 $links_list[] = '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> '; 

This is the line that constructs the actual link. Change it to

 $links_list[] = 'XXX<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . (int)$categories_tab->fields['categories_id']) . '">' . $categories_tab_current . '</a> '; 

Then look at your page. If you don't see the XXX then you are editing the wrong version of this file.

Nick

27 Apr 2010, 4:39 PM
#7
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

I verified that there is a category called 'Sale'.

I copied the categories_tabs.php file into my template folder from

zencart/includes/modules/ to

zencart/includes/modules/mytemplatefolder/.

Let me know if I need to be grabbing the file from another location.

Thanks.

http://tregreekboutique.com/zencart

27 Apr 2010, 6:08 PM
#8
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

Well, we must be in the wrong file. And the only explanation for that is the drop downs. Which add-on have you used? There are several :-)

Nick

28 Apr 2010, 2:08 AM
#9
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

I added on the Zencart Category Tab Simple Dropdown Menu add-on. The file added was the tpl_modules_categories_tabs.php file located in my zencart/includes/templates/mytemplate/templates folder. The code content contained in the file is attached.

I also added the Categories Dressing add-on as well. Didn't know if the code needed to be added to any of the files for this add-on.

Let me know if this pinpoints where the font color link can be changed.

Thanks!

http://www.tregreekboutique.com/zencart

#navCatTabsDropdown li ul 
{
	visibility:hidden;
	position:absolute;
	padding: 0.5em;
	z-index: 100;
}

#navCatTabsDropdown li:hover ul 
{
	visibility:visible;
	background-color: #ffffff;
/*	border: 2px outset #315427;*/
        border: 1px dotted #7a7a7a;
	white-space:nowrap;
}
</style>

<?php
if (CATEGORIES_TABS_STATUS == '1') 
{
	echo '<div id="navCatTabsWrapper">';
	echo '<div id="navCatTabs">';
	echo '<div id="navCatTabsDropdown">';
	echo '<ul>';

	$categories_tab_query = "SELECT c.categories_id, cd.categories_name FROM ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id=cd.categories_id AND c.parent_id= '0' AND cd.language_id='" . (int)$_SESSION['languages_id'] . "' AND c.categories_status='1' ORDER BY c.sort_order, cd.categories_name;";
	$categories_tab = $db->Execute($categories_tab_query);

	while (!$categories_tab->EOF) 
	{
	// currently selected category
		echo '<li>';
		echo '<a class="category-top" href="'.zen_href_link(FILENAME_DEFAULT,'cPath=' . (int)$categories_tab->fields['categories_id']).'">'; 
		if((int)$cPath == $categories_tab->fields['categories_id']) 
		 echo '<span class="category-subs-selected">'.$categories_tab->fields['categories_name'].'</span>';
		else 
		 echo $categories_tab->fields['categories_name'];

		echo '</a>';
		$subcategories_tab_query="SELECT c.categories_id, cd.categories_name FROM ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id=cd.categories_id AND c.parent_id= '".(int)$categories_tab->fields['categories_id']."' AND cd.language_id='" . (int)$_SESSION['languages_id'] . "' AND c.categories_status='1' ORDER BY c.sort_order, cd.categories_name;";
		$subcategories_tab=$db->Execute($subcategories_tab_query);
		if($subcategories_tab->RecordCount()>0)
		{
			echo '<ul>';
			while (!$subcategories_tab->EOF) 
			{
				//$cPath_new=zen_get_path($subcategories_tab->fields['categories_id']);
				//$cPath_new=str_replace('=0_', '=', $cPath_new);
				$cPath_new="cPath=".$categories_tab->fields['categories_id'].'_'.$subcategories_tab->fields['categories_id'];
				echo '<li><a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">'.$subcategories_tab->fields['categories_name'].'</a></li><br />';
				$subcategories_tab->MoveNext();
			}
			echo '</ul>';
		}
		$products_tab_query="SELECT p.`products_id`, pd.`products_name`, pd.`language_id` FROM ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd WHERE p.`products_status`=1 AND p.`master_categories_id`='".(int)$categories_tab->fields['categories_id']."' AND p.`products_id`=pd.`products_id` AND pd.`language_id`='".(int)$_SESSION['languages_id']."' ORDER BY p.`products_sort_order`;";
		$products_tab=$db->Execute($products_tab_query);
		if($products_tab->RecordCount()>0)
		{
			echo '<ul>';
			while (!$products_tab->EOF) 
			{	
				$cPath_new=zen_get_path($categories->fields['categories_id']);
				$cPath_new=str_replace('=0_', '=', $cPath_new);
				echo '<li>'.'<a href="'.zen_href_link(zen_get_info_page($products_tab->fields['products_id']),$cPath_new. '&products_id=' . $products_tab->fields['products_id']) . '">'.$products_tab->fields['products_name'].'</a></li><br />';
				$products_tab->MoveNext();
			}
			echo '</ul>';
		}
		echo '</li>';
		$categories_tab->MoveNext();
	}
	echo '</ul>';
	echo '</div>';
	echo '</div>';
	echo '</div>';
}
?>
28 Apr 2010, 7:49 AM
#10
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

Ha, Ha. Well, the first bit of this thread will be useful for other people who want to do the same thing but haven't installed that mod.

At about line thirty:

    while (!$categories_tab->EOF) 
    {
    // currently selected category
        echo '<li>';

// BOF NEW CODE
if ($categories_tab->fields['categories_name']=='Sale'){
  $red_style =  ' red_menu';
}else{
  $red_style =  '';
}	
//EOF NEW CODE - 
//$RED_STYLE IS INSERTED IN LINE BELOW

        echo '<a class="category-top'.$red_style.'" href="'.zen_href_link(FILENAME_DEFAULT,'cPath=' . (int)$categories_tab->fields['categories_id']).'">'; 

Haven't tested this as I would need to install the mod but it should work fine. Let me know

Nick

29 Apr 2010, 3:55 PM
#11
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

Hi Nick,

I thought that would work but it didn't. :(

I can see exactly what you are doing with the code, so I'm not sure why the font color did not change.

I still have the change saved to the website and was taking a look at the source code that is generated. Not sure if that would help.

http://www.tregreekboutique.com/zencart

29 Apr 2010, 4:36 PM
#12
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

A bit annoying.:smile:

I just installed the menu mod on a test server and made the changes that I suggested. It works fine.

The changes have two parts:

  1. Make the changes in the post above.
  2. Add a stylesheet rule for class red_menu.

Did you do both? Are the changes still in place? Actually I can see that the styleshhet rule is in place. So, that leaves....

I am 99.9percent sure that the code works. Which means that for some reason the conditional statement is not selecting the correct menu item. Try one of the other categories perhaps 'Custom Orders' and see if that works.

Either that or you are still not editing the correct version of the file. have you an override version of this file?

29 Apr 2010, 7:49 PM
#13
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

It's very annoying!! :frusty:

I am modifying my override file. I added the red_menu style to the bottom of the stylesheet. Should it be added in another portion of the stylesheet?

I'm at a complete lost. Just don't understand why it's not working.

29 Apr 2010, 8:16 PM
#14
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

Ok. We are just going to check that we are working on the right file. Sorry, but we need to check.

Find this line :

    echo '<div id="navCatTabsDropdown">'; 

and change it to:

    echo '<div id="navCatTabsDropdown XXXX">'; 

This should not change a thing on the rendered page but if you look at the source code you should see the XXXX. If you don't see it then we are in the wrong file. If you do then we at least know that we are editing the right file.

It's just a bit annoying!

29 Apr 2010, 9:26 PM
#15
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

So, I made the change. It did however change the actual layout of the categories and it does appear in the source code.

Check it out and let me know what I should do to proceed.

http://www.tregreekboutique.com/zencart

30 Apr 2010, 6:54 AM
#16
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

OK. That make sense.

Take that out and find the line that starts:

        echo '<a class="category-top"

and change that to:

        echo '<a class="category-top  YYYY"

And lets have a look at the source code then.

30 Apr 2010, 7:10 AM
#17
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

Just made the change and it's showing in the source code!

So that means it's the right file, right?? :dontgetit

30 Apr 2010, 9:01 AM
#18
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

OK - we are narrowing it down!

You can take out that last change, please.

Now we are going to go back to my initial code.

   // currently selected category
        echo '<li>';

// BOF NEW CODE
if ($categories_tab->fields['categories_name']=='Sale'){
  $red_style =  ' red_menu';
}else{
  $red_style =  '';
}	
//EOF NEW CODE - 
//$RED_STYLE IS INSERTED IN LINE BELOW

        echo '<a class="category-top'.$red_style.'" href="'.zen_href_link(FILENAME_DEFAULT,'cPath=' . (int)$categories_tab->fields['categories_id']).'">';

Let's change it to:

// BOF NEW CODE
if ($categories_tab->fields['categories_name']=='Sale'){
  $red_style =  ' red_menu';
}else{
  $red_style =  ' no_change';
}	
//EOF NEW CODE

Can you put that up and let me have a look?

30 Apr 2010, 2:40 PM
#19
techiegirl avatar

techiegirl

New Zenner

Join Date:
Apr 2010
Posts:
68
Plugin Contributions:
0

Re: Changing Font Color of Single Category Link

Okay, I've removed the 'YYYY' from the code and re-added the portion of the original updated code.

Let me know what you determine.

Thanks!

30 Apr 2010, 3:12 PM
#20
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Changing Font Color of Single Category Link

OK.

Can I confirm that you have this line edited too as shown in the earlier post:

        echo '<a class="category-top'.$red_style.'" href="'.zen_href_link(FILENAME_DEFAULT,'cPath=' . (int)$categories_tab->fields['categories_id']).'">';

Perhaps you missed this part of the changes? Maybe the instructions were not clear.