Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Excluding categories from certain attribs

Excluding categories from certain attribs

Locked

Views: 1,637

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
26 Sep 2007, 3:29 PM
#1
tatiana77 avatar

tatiana77

Zen Follower

Join Date:
May 2007
Posts:
114
Plugin Contributions:
0

Excluding categories from certain attribs

Hi, I had to hardcode my 'View Size Chart' because I couldn't find a better way to do this. Please check it out:

http://www.wolfandrabbit.com/index.php?main_page=product_info&cPath=65_73&products_id=205

It looks good and I like it that it's a subtle button to view the size chart, but I want to exclude the link on categories that don't require a size chart, such as Toys and Bath and Body products.

Please let me know if anyone can help me figure this out.
I tried going about it the 'attribute' way and have no idea how to do it...I'm open for suggestions.
Thanks,
Tatiana

26 Sep 2007, 4:22 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Excluding categories from certain attribs

In tpl_product_info_display.php, wrap your size chart link code in an "if" test that triggers based on either the list of categories to include or to exclude (depending on which list is easier).

<!--bof Size chart link -->
<?php if (ereg("(^23$|^23_)",$cPath)) { //replace 23 with your categories' cPaths per instructions ?>
<br class="clearBoth" /><br/>
<a href="javascript:popupDetails('http://www.wolfandrabbit.com/includes/templates/WR/images/sizechart.gif')"><img src="http://www.wolfandrabbit.com/includes/templates/WR/images/attributes/viewoursizechart.gif"/></a>
<?php } ?><!--eof Size chart link -->

This is written to display the link for categories in the list.
To not display for categories in the list, add a ! before ereg:

if (!ereg("(^23$|^23_)",$cPath)) {

To add your categories to the list:

if (ereg("(^23$|^23_)",$cPath)) {

^23$ means "exactly 23", | means "or", and ^23_ means "begins with 23_".
To add category 2 and subcat 7_13, the list would look like this:
(^23$|^23_|^2$|^2_|^7_13$) and the whole line would look like this:

if (ereg("(^23$|^23_|^2$|^2_|^7_13$)",$cPath)) {

26 Sep 2007, 4:59 PM
#3
tatiana77 avatar

tatiana77

Zen Follower

Join Date:
May 2007
Posts:
114
Plugin Contributions:
0

Re: Excluding categories from certain attribs

Hi Glenn thanks for the quick reply,

Do you mean I should do this in tpl_modules_attributes.php?

26 Sep 2007, 5:04 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Excluding categories from certain attribs

If that is where the output code is, then yes. Which file has the <!--bof Size chart link --> tag?

26 Sep 2007, 5:17 PM
#5
tatiana77 avatar

tatiana77

Zen Follower

Join Date:
May 2007
Posts:
114
Plugin Contributions:
0

Re: Excluding categories from certain attribs

This is my new code:

<!--bof Size chart link --> <?php if (!ereg("(^68_|^77_)",$cPath)) { //replace 23 with your categories' cPaths per instructions ?>

<br class="clearBoth" /><br/>
<a href="javascript:popupDetails('http://www.wolfandrabbit.com/includes/templates/WR/images/sizechart.gif')"><img src="http://www.wolfandrabbit.com/includes/templates/WR/images/attributes/viewoursizechart.gif"/></a>

<?php } ?> <!--eof Size chart link -->

It doesn't seem to make any difference... did I do something wrong?
Thanks for your help.

26 Sep 2007, 6:36 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Excluding categories from certain attribs

Try it with the "positive" - (without ! ) just to see if that works. I know sometimes the direct negative doesn't give the desired results, but it's been a while since I dealt with that and I don't remember offhand exactly how I solved the problem.

Another possibility is your phrasing of the categories.
(^68_|^77_)
will affect only subcategories of 68 and 77, not the top categories. The ereg function is very strict in how it looks for patterns, which allows for great specificity, but you need to specify every possibility.

26 Sep 2007, 7:37 PM
#7
tatiana77 avatar

tatiana77

Zen Follower

Join Date:
May 2007
Posts:
114
Plugin Contributions:
0

Re: Excluding categories from certain attribs

Hm nope, I get this error message on the product page:

Parse error: parse error, unexpected $ in /homepages/44/d205662926/htdocs/includes/templates/WR/templates/tpl_modules_attributes.php on line **89

Again, here's my code for your reference:

<!--bof Size chart link --> <?php if (ereg("(^68$|^77$)",$cPath)) { ?>

<br class="clearBoth" /><br/>
<a href="javascript:popupDetails('http://www.wolfandrabbit.com/includes/templates/WR/images/sizechart.gif')"><img src="http://www.wolfandrabbit.com/includes/templates/WR/images/attributes/viewoursizechart.gif"/></a>

<!--eof Size chart link -->

**

26 Sep 2007, 7:46 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Excluding categories from certain attribs

Your edit lost the

<?php } ?>

in front of

<!--eof Size chart link -->.
26 Sep 2007, 7:50 PM
#9
tatiana77 avatar

tatiana77

Zen Follower

Join Date:
May 2007
Posts:
114
Plugin Contributions:
0

Re: Excluding categories from certain attribs

Aaah bee-oo-tee-full!

Thank you Glenn. I tested it on the bath and body and no size chart, but works perfectly on the clothing categories!!

Yay!

:laugh::laugh::laugh:

PS The ! for unwanted categories did the trick too