If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Ampersands in category and manufacturer names

Ampersands in category and manufacturer names

Locked

Started by nigelt74 on 4 Dec 2007, 10:51 PM · Views: 893

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
4 Dec 2007, 10:51 PM
#1
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #1 by nigelt74

Hi all

ampersand = & --for those who don't know

I'm back, so be very afraid

I just ran my site through a validator and got 17 errors of which 16 are due to ampersands in either category names or manufacturer names, is there a way around this

i would prefer to get a solution that works when the names are entered on the admin side but I am not 100% sure where to look on the admin side (I've kind of left it alone) but i am guessing i will need to add some htmlspecialchars code somewhere

as a last resort i thought about putting a some sort of string replace function in the categories and manufacturers boxes

I have searched and either i am spelling ampersand wrong or I am the only person having this problem, (and no it doesn't make me feel special)

any help would be greatly appreciated

edit------
Ok Um well promise not to laugh but i was searching on a completely different unrelated site, when i search on here some results do appear

Webzings Design
Semi retired from Web Design

5 Dec 2007, 11:38 PM
#2
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Post #2 by nigelt74

And i'm back again

Ok a rough Guide for anyone else who has this issue

you need to edit this file

includes/templates/< your template >/sideboxes/tpl_categories.php

(if you don't have that file in that location you will need to copy it from
includes/templates/template_default/sideboxes/ into the sideboxes directory of your template)

find this bit of code (line 36 for me)

if ($box_categories_array[$i]['current']) {
if ($box_categories_array[$i]['has_sub_cat']) {
$content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
} else {
$content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
}
} else {
$content .= $box_categories_array[$i]['name'];
}

replace with

if ($box_categories_array[$i]['current']) {
if ($box_categories_array[$i]['has_sub_cat']) {
$content .= '<span class="category-subs-parent">' . htmlspecialchars(html_entity_decode($box_categories_array[$i]['name'], ENT_QUOTES)) . '</span>';
} else {
$content .= '<span class="category-subs-selected">' . htmlspecialchars(html_entity_decode($box_categories_array[$i]['name'], ENT_QUOTES)) . '</span>';
}
} else {
$content .= htmlspecialchars(html_entity_decode($box_categories_array[$i]['name'], ENT_QUOTES));
}

the reason i am using the html_entity_decode in addition to the htmlspecialchars is that my subcategory indent is done by 2   which if i don't do decode first ends up getting recoded by the htmlspecialchars as   which becomes visible to the customer

I can't find the other sections I should be changing although i haven't looked overly hard yet

The manufacturers on has me beat, as i can't find where the content (manufacturers name) of the box is coming from
Also meta tags and product names i have to look at still

Webzings Design
Semi retired from Web Design