You are here:  » category special symbols

Support Forum



category special symbols

Submitted by ZiiPJester on Mon, 2011-01-17 15:09 in

Hi David,

I'm sure that this has been raised before, I vaguely remember a simular thread about it, but couldn't find exactly what I was after.

The trouble I have is categories, especially those from Merchants like John Lewis who use the > symbol as a spacer between different category levels. Useful, considering > is the closing symbol of a HTML tag. I guess people that make datafeeds don't ever do any coding.

Anyhow, I can appreciate that > is removed upon import due to security. Rather than just filter it, where is the code so that it could be changed to say a slash or something - and by doing so, would it create any further problems elsewhere in the code?

Kind regards,

James

Submitted by support on Mon, 2011-01-17 16:28

Hi James,

As it stands the category value is normalised (made safe) _before_ user filters are applied; so the first stage in dealing with this would be to move the normalisation to afterwards. Look for the following block of code beginning at line 152 of includes/admin.php

    if ($admin_importFeed["field_category"])
    {
      $importRecord["category"] = $record[$admin_importFeed["field_category"]];
    }
    elseif($admin_importFeed["user_category"])
    {
      $importRecord["category"] = $admin_importFeed["user_category"];
    }
    else
    {
      $importRecord["category"] = "";
    }
    if ($importRecord["category"])
    {
      $importRecord["category"] = tapestry_normalise($importRecord["category"]);
    }

CUT the above, and PASTE it back in immediately BEFORE the following comment, at line 201:

    /* drop record if set by user filters filters */

With that modification in place, you would then be able to Search and Replace the ">" character from your category values with something else, but bear in mind that "/" is also a protected character (removed by normalisation).

What might be better still is to add the Explode filter to your site. The code is in the following post:

http://www.pricetapestry.com/node/339#comment-3191

With the Explode filter in place, you could add a new Explode filter to the Category field, and enter ">" (without the quotes) as the Explode Character or String, and -1 as the return index. This will return the lowest level category from a category field containing "MasterCategory > Subcategory1 > Subcategory2"...

Thanks for your additional comments also! It has been my intention to look into the forum side of things now that it is becoming quite large and with multiple versions to support...!

Cheers,
David.
--
PriceTapestry.com

Submitted by ZiiPJester on Mon, 2011-01-17 19:04

Cheers David,

Sadly i'm having trouble with this.. its not working :(
I tried it with both the Explode and even the Search & Replace and it wasn't working.

As a test, I even commented out the line:

$importRecord["category"] = tapestry_normalise($importRecord["category"]);

..as I presume that's the call to the normalisation function, and it still didn't work.

I'm using the latest release of PT. The only modifications i've made on the domain is to the /HTML/ directory and to some SearchExternal - this is a fresh install.

I don't think i'm being an idiot :) Any ideas?

Kind regards,

James

Submitted by support on Tue, 2011-01-18 09:29

Hi James,

It's possible that the > is actually present in the feed as it's HTML entity - which is > so have a go either using that as the Explode Character or String, or as the Search field in a Search and Replace.

If that doesn't do the trick, if you could let me know the installation URL (i'll remove before publishing your reply) and filename of the feed containing the category values that you are working I'll download it to my test server and take a look for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by ZiiPJester on Tue, 2011-01-18 13:30

Hi David,

I tried > but it doesn't seem to be working either. When I register the feed, is shows up in the example as: "Home & Garden > Garden & Conservatory > Picnicware > Barbecue Accessories"

It seems strange to me that they use the HTML code for the & , but don't for the > .

Anyhow, I would appreciate it if you could have a little look.

Submitted by support on Tue, 2011-01-18 15:42

Hi James,

Just tried to access the site but the username/password from your post didn't work for me - could you check and perhaps drop me an email with the details required...

Cheers,
David.
--
PriceTapestry.com