Forums / Developer / RSS Import Handler: need information

RSS Import Handler: need information

Author Message

Andrey Astakhov

Tuesday 07 October 2008 9:55:10 am

I have to import special rss item tags as object attributes. Unfortunately standard eZ Publish functionality doesn't allow it.

I see such block in site.ini:

#
# Settings for RSS
#
[RSSSettings]
# RSS import handler Extension settings
# Must be placed in <extension directory>/<active extension>/rss/ezrssimporthandler.php
ActiveExtensions[]

Presumably there is a possibility to create own rss import handlers. Does anybody have documentation and/or expirience re this topic?

Łukasz Serwatka

Tuesday 07 October 2008 1:27:54 pm

Hi,

This is used to create your own RSS field definition array:

Basically you need to create a class which implementing rssFieldDefinition public method

Example extension:

// class name is construct as <active_extension> +  'rssimport'
// 'rssimport' suffix must be part of class name
class MyCustomFieldsrssimport
{
    public function rssFieldDefinition()
    {
        return array( 'item' => array( 'elements' => array( 'title',
                                                                    'link',
                                                                    'description',
                                                                    'author',
                                                                    'category',
                                                                    'comments',
                                                                    'guid',
                                                                    'pubDate' ) ),
                              'channel' => array( 'elements' => array( 'title',
                                                                       'link',
                                                                       'description',
                                                                       'copyright',
                                                                       'managingEditor',
                                                                       'webMaster',
                                                                       'pubDate',
                                                                       'lastBuildDate',
                                                                       'category',
                                                                       'generator',
                                                                       'docs',
                                                                       'cloud',
                                                                       'ttl' ) ) );
    }
}

Put that class in

extension/MyCustomFields/rss/MyCustomFieldsrssimport.php

Then enable it in site.ini.append.php as

[RSSSettings] 
ActiveExtensions[]=MyCustomFields

Clear all the cache and go to admin interface, then check available filed definition in RSS import.

Beware of typos, I did not test it with eZ Publish instance.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Andrey Astakhov

Wednesday 08 October 2008 3:11:23 am

Thank you, Lukasz.

Is rssFieldDefinition a single metod i could implement? Is it posiible to override import process?

E.g could i insert my own parsing of rss items before rssimport script?

Łukasz Serwatka

Wednesday 08 October 2008 4:09:19 am

That method has to return array with RSS definition (you can include here your custom RSS tags), which you can map later to the content object attributes in RSS import view IIRC. You can not put in that method your RSS parsing code I'm afraid.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog