I used the information from...
To write a small custom module that provides a custom parser using Simplepie. I modified the code to look like the code below.
The code was taken from the examples from The developer's guide to Feeds.
Everything seems to work fine since I can see my Custom Parser under the Feeds UI and it also displays the custom elements under the mapping section.
But when I for example map one of the custom fields/elements to the Title or Body for example the data seems to be empty.
Am I being daft here? My skills as a coder is mediocre at best...
/**
* A simple parser that extends FeedsSimplePieParser by adding support for a
* couple of Custom Namespace tags.
*/
class MyParser extends FeedsSimplePieParser {
/**
* Add the extra mapping sources provided by this parser.
*/
public function getMappingSources() {
return parent::getMappingSources() + array(
'g_zoning' => array(
'name' => t('g:zoning'),
'description' => t('Zoning.'),
),
'g_id' => array(
'name' => t('g:id'),
'description' => t('ID'),
),
'c_property_id' => array(
'name' => t('c:property_id'),
'description' => t('Property ID.'),
),
);
}
/**
* Parse the extra mapping sources provided by this parser.
*/
protected function parseExtensions(&$item, $simplepie_item) {
$google_namespace = 'http://base.google.com/ns/1.0';
$custom_namespace = 'http://base.google.com/cns/1.0';
if ($value = $simplepie_item->get_item_tags($google_namespace, 'zoning')) {
$item['g_zoning'] = $value[0]['data'];
}
if ($value = $simplepie_item->get_item_tags($custom_namespace, 'property_id')) {
$item['c_property_id'] = $value[0]['data'];
}
if ($value = $simplepie_item->get_item_tags($google_namespace, 'id')) {
$item['g_id'] = $value[0]['data'];
}
}
}
I must also mention that this behavior seems manifests itself when I'm using the Google Base Namespaces...
Any information would be greatly appreciated...
Comments
Comment #1
alex_b commentedFeeds wise this code looks good. Are you sure that your parsing code actually yields the elements as expected? I. e. if you dump $item at the end of parseExtensions() to the screen, can you see the values as expected?
Comment #2
alex_b commentedClosing support request after multiple weeks of inactivity.