RSS and the keywords attribute

Author Message

Børge Warvik

Monday 07 May 2007 1:20:59 am

Hi,

In our system we're going to use the keywords attribute in classes to display relevant nodes to the node that is being viewed by the user.

At the moment I'm trying to set this up for our RSS imports. We're buying external news, and the news are delivered as a feed that I'm importing. The feed is RSS 2.0. I've told the company that delivers the feed to put the keywords they are using to create the feed into the RSS 2.0 "comments" field. In the RSS classed used to store the feed items I've added a field called Keywords of datatype keywords.

The keywords in the feed are a comma separated list of words. When done, I'm activating and start to import the items. Everything is working fine, except that the keywords aren't being imported into the keywords field in the RSS class.

Any ideas why this is happening?

Thanks,
Børge Warvik

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

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

eZ debug

Timing: Jan 18 2025 14:55:44
Script start
Timing: Jan 18 2025 14:55:44
Module start 'layout'
Timing: Jan 18 2025 14:55:44
Module start 'content'
Timing: Jan 18 2025 14:55:46
Module end 'content'
Timing: Jan 18 2025 14:55:46
Script end

Main resources:

Total runtime1.6436 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0098 587.9141152.6250
Module start 'layout' 0.00980.0024 740.539139.4609
Module start 'content' 0.01211.6301 780.0000596.0078
Module end 'content' 1.64230.0013 1,376.007812.1641
Script end 1.6435  1,388.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.1875160.0002
Check MTime0.00130.0783160.0001
Mysql Total
Database connection0.00590.361110.0059
Mysqli_queries1.573395.7210590.0267
Looping result0.00060.0361570.0000
Template Total1.602897.520.8014
Template load0.00180.112020.0009
Template processing1.601097.407520.8005
Template load and register function0.00010.006810.0001
states
state_id_array0.00070.045010.0007
state_identifier_array0.00120.070720.0006
Override
Cache load0.00160.0962310.0001
Sytem overhead
Fetch class attribute can translate value0.00060.034030.0002
Fetch class attribute name0.00190.114960.0003
XML
Image XML parsing0.00490.299230.0016
class_abstraction
Instantiating content class attribute0.00000.000560.0000
General
dbfile0.01210.7343300.0004
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs