RSS and the keywords attribute

RSS and the keywords attribute

Monday 07 May 2007 1:20:59 am - 2 replies

Author Message

Egil Fujikawa Nes

Thursday 10 May 2007 10:25:36 am

Hi Børge,

I'm not sure I can give you a out-of-the-box solution, but I have a clue that you can work with. I experienced problem with importing data to the ezkeyword datatype but not from the default RSS import script in eZ.

When I look into the rssimport.php in you will see this code to write the value:

function setObjectAttributeValue( &$objectAttribute, $value )
{
    if ( $value === false )
    {
        return;
    }

    $dataType = $objectAttribute->attribute( 'data_type_string' );
    if ( $dataType == 'ezxmltext' )
    {
        setEZXMLAttribute( $objectAttribute, $value );
    }
    elseif ( $dataType == 'ezurl' )
    {
        $objectAttribute->setContent( $value );
    }
    else
    {
        $objectAttribute->setAttribute( 'data_text', $value );
    }

    $objectAttribute->store();
}

This shows that ezkeywords just will be tried inserted with the commaseparated string in setAttribute.

What you need to do in order to store a eZkeyword is to initialize a keyword object, my import code looks like this:

        $key = new eZKeyword();
        $key->initializeKeyword( $value );
        $keyword = $myContentObjectAttributes['keyword_trigger'];
        $keyword->setContent( $key );
        $keyword->store();

What I suggest is that you try to edit your rssimport.php to something like this:

function setObjectAttributeValue( &$objectAttribute, $value )
{
    if ( $value === false )
    {
        return;
    }

    $dataType = $objectAttribute->attribute( 'data_type_string' );
    if ( $dataType == 'ezxmltext' )
    {
        setEZXMLAttribute( $objectAttribute, $value );
    }
    elseif ( $dataType == 'ezurl' )
    {
        $objectAttribute->setContent( $value );
    }
    elseif ( $dataType == 'ezkeyword' )
    {
        $key = new eZKeyword();
        $key->initializeKeyword( $value );
        $objectAttribute->setContent( $key );
    }
    else
    {
        $objectAttribute->setAttribute( 'data_text', $value );
    }

    $objectAttribute->store();
}

I don't know if this will works out, but hopefully you got a idea about where the problem is located.

Good luck Børge :)

BuildCMS - Av. Paulista 777, 15° Andar - CEP: 01311-100 - São Paulo
URL: http://www.buildcms.com

Łukasz Serwatka

Thursday 10 May 2007 1:54:36 pm

There was a bug [1] fixed by Kåre in:
stable/3.8 rev. 18847
stable/3.9 rev. 18848
trunk rev. 18849

[1] http://issues.ez.no/10713

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

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.