You are here:  » Config.advance.php for custom filenames from networks with no header rows.


Config.advance.php for custom filenames from networks with no header rows.

Submitted by BobL on Fri, 2014-05-16 01:37 in

Hi David,
I hope all is well with you.
I was wondering if its possible to have step2 of the register to pull a custom array into the fields when registering a feed with no header row of field names?
As an example I name my files from Linkshare with merchant_LS_merchantid.txt
$config_fieldsNet_LS = Array("field1","field2",etc.);
Would it be possible to pick the _LS_ out of the filename and parse the array into the fields?
And if it didn't have a $config_fieldsNet use the header rows like normal?

Thanks in advance.
Bob L.

Submitted by support on Fri, 2014-05-16 09:12

Hello Bob,

The auto-generated field names FIELD1, FIELD2 etc. when there is no header row can be added to the $config_commonFields array in config.advanced.php as normal, so if it is only the one network that this applies to that would be the most straight forward thing to do. But of course, if you work with more than one feed format without header rows, that is discernible by studying the filename, then it would be straight forward to override $config_commonFields in admin/feeds_register_step2.php as you describe. To try this, look for the following code at line 14:

  $filename = $_GET["filename"];

...and REPLACE with:

  $filename = $_GET["filename"];
  if (strpos($filename,"_LS_")!==FALSE)
  {
    $config_commonFields = array(
      "name" => array("FIELD1"),
      "description" => array("FIELD2"),
      "image_url" => array("FIELD3"),
      "price" => array("FIELD4"),
      "category" => array("FIELD5"),
      "brand" => array("FIELD6")
    );
  }

Simply repeat that block with different values of _LS_ as required, with FIELD1, FIELD2 etc. configured as required for that format.

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Fri, 2014-05-16 13:44

Bob L.

Hi David

Yes, I work with more than one network that doesn't have field names.
With several installs under a main install, what I've done is created a my.config.advanced.php in the top level and moved all the $config_fieldSet there, so when I make a change it effects all installs.
That way I don't have to keep editing every install.

But I see where you're at there, so I'll be fine.
Many thanks for the great support.
Love you program. and the great support.

As always, Cheers