You are here:  » paidonresults.com feeds

Support Forum



paidonresults.com feeds

Submitted by cataleptic on Tue, 2007-02-20 00:25 in

Hi all,
I have a problem with feeds from this network.

They work really well. But the categories have more than one category in the line: e.g
"Electronics &amp Televisions 7amp".

Problem is I want the "amp" to be removed and only use the last category item.

I hope i'm making myself clear.

Below is how it looks in the feed:
<Category><![CDATA[Computing &amp; Gaming&gt;Laptops &amp; Handhelds&gt;Laptops]]></Category>

Submitted by support on Tue, 2007-02-20 08:33

Hi,

There are a couple of modifications you will need to make to be able to handle this sort of category field, based on the explode filter described in this thread. Firstly, the semi-colon character is the obvious one to split the string upon; and so this must be permitted within the import record handler as this character is normally stripped.

In includes/admin.php look for the following code on line 170:

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

Change this as follows to allow the ";" character:

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

Now, i'm assuming that there could be any number of categories in the list, and so the last one isn't always the 3rd for example. Therefore, you will need a modified version of the explode filter that will accept a negative index to allow you to specify the n'th from the end. Here's the code to add to includes/filters.php:

<?php
  
/*************************************************/
  /* explode                                       */
  /*************************************************/
  
$filter_names["explode"] = "Explode";
  function 
filter_explodeConfigure($filter_data)
  {
    print 
"Explode Character or String:<br />";
    print 
"<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    
widget_errorGet("text");
    print 
"<br />";
    print 
"Return Index: (zero based)<br />";
    print 
"<input type='text' size='3' name='index' value='".widget_safe($filter_data["index"])."' />";
    
widget_errorGet("index");
  }
  function 
filter_explodeValidate($filter_data)
  {
    if (!
$filter_data["text"])
    {
      
widget_errorSet("text","required field");
    }
    if (!
$filter_data["index"])
    {
      
widget_errorSet("index","required field");
    }
  }
  function 
filter_explodeExec($filter_data,$text)
  {
    
$parts explode($filter_data["text"],$text);
    
$index intval($filter_data["index"]);
    if (
$index 0)
    {
      
$index count($parts) + $index;
    }
    return 
$parts[$index];
  }
?>

To use this, register an "Explode" filter against the category field, use ";" (without the quotes) as the explode character or string; and finally use -1 as the return index which will give you the last element of the exploded array...

Hope this helps!
Cheers,
David.

Submitted by cataleptic on Wed, 2007-02-21 02:38

Hi David, thats great seems to work on some merchants.

I am still getting the amp instead of "&" please have a look at my categories page:

http://www.pricebargin.co.uk/categories.php
I've tried to clean it up as much as I can, but I cant see where im going wrong.

Submitted by support on Wed, 2007-02-21 09:11

Hi,

I think you're seeing "amp" because the & character has been stripped, and the ";" character has been removed by virtue of splitting the string on that character.

What I think you should do is first modify the same line in includes/admin.php as described above, but to also permit &, as follows:

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

Then, in the Explode filter, instead if splitting on just ";", use the full string, i.e. "&gt;".

This should preseve the & entity in the category values and they should then be displayed correctly...

Cheers,
David.