Hi,
I was wondering whether anyone has managed to pass an additional variable through magic parser?
Bascially I want to do something like this:
MagicParser_parse($url,'myRecordHandler($brandID)',"xml|PRODUCTS/PRODUCT/");
And have it be passed through to my record handler untouched. Any ideas?
I need to do this because a product feed I'm working with doesn't include a brand ID and I need to be able to reliably distinguish between brands.
Cheers,
Karl
David,
Of course! Am just dusting off my php skills after a bit of an interval... forgot about global variables! Thanks.
Karl
Hello Karl,
As there is nothing else that can alter $brandID the thing to do is simply to make it a global variable, for example:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
global $brandID;
// ...use $record and $brandID here...
}
MagicParser_parse($url,'myRecordHandler',"xml|PRODUCTS/PRODUCT/");
$brandID = 1234;
?>
Hope this helps,
Cheers,
David.