You are here:  » multiple categories in same csv field problem

Support Forum



multiple categories in same csv field problem

Submitted by Klyde on Mon, 2008-09-01 19:00 in

Hello,

I have a problem with the importation of a csv file which use multiple category id in the same field.

The field is limited by pipes, and each categories in the field are separated by commas.
ex:

...|534,532|...

Is there a way to give multiple categorys to an article (I don't think so). Otherwise, how can I setup a filter which only keep the first category and just skip the others?

Thanks for your help

Submitted by support on Mon, 2008-09-01 19:15

Hi,

There's a new "Explode" filter described in this thread:

http://www.pricetapestry.com/node/2017

After adding the code from that thread to your includes/filter.php, you can then register a new "Explode" filter against the category field, use "," (without the quotes) as the explode character or string, and a return index value of "0" (zero - without the quotes). This will just return the first item in the comma separated list!

Cheers,
David.

Submitted by Klyde on Mon, 2008-09-01 20:11

Ok, I just add this new filter but unfortunatly I can't set "Return Index" to 0. It show me this error message "required field". If I set it to 1 it don't display this error message.

Submitted by support on Mon, 2008-09-01 20:56

Hi,

Sorry about that, i've fixed the code in the other thread so that return index can be zero - if you update the code it should then work...

Cheers,
David.

Submitted by Klyde on Mon, 2008-09-01 21:24

Perfect, it works now.
Thanks a lot.

Submitted by Klyde on Mon, 2008-09-01 22:11

Ggggrrrr. In fact I have another strange bug with categorys, but it's not due to the filter. If I remove filters the problem is always here.

When I import feed, the script consider ...|539,535,531,486,472,470|... as 539535531486472470 and create a category 539535531486472470.

Submitted by support on Tue, 2008-09-02 06:41

Hi,

This is down to the "normalisation" process that removes certain characters from the field values to make them save and consistent throughout the site. If you like, because of the way your category values are formatted you could remove normalisation for the category field. To do this, look for the following code on line 172 of includes/admin.php:

$record[$admin_importFeed["field_category"]] = tapestry_normalise($record[$admin_importFeed["field_category"]]);

...and simply delete or comment out this line. After doing so (and re-importing), check functionality carefully throughout the site for any side effects of allowing these characters into the category field - especially if using search engine friendly URLs ($config_useRewrite = TRUE) - as we may need to look at other changes to accommodate this...

Cheers,
David.

Submitted by Klyde on Tue, 2008-09-02 06:58

Thanks a lot, this is now ok.

Thanks for your help