Forums / Setup & design / RSS and the keywords attribute

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

eZ debug

Timing: Jan 18 2025 10:32:47
Script start
Timing: Jan 18 2025 10:32:47
Module start 'content'
Timing: Jan 18 2025 10:32:47
Module end 'content'
Timing: Jan 18 2025 10:32:47
Script end

Main resources:

Total runtime0.1528 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 588.8594180.8359
Module start 'content' 0.00580.0056 769.695397.9922
Module end 'content' 0.01150.1413 867.6875526.8047
Script end 0.1527  1,394.4922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.2757200.0002
Check MTime0.00140.8840200.0001
Mysql Total
Database connection0.00080.517710.0008
Mysqli_queries0.108470.96981410.0008
Looping result0.00140.94031390.0000
Template Total0.140892.110.1408
Template load0.00100.626310.0010
Template processing0.139891.507710.1398
Override
Cache load0.00070.447010.0007
Sytem overhead
Fetch class attribute can translate value0.00050.308910.0005
XML
Image XML parsing0.00020.130910.0002
General
dbfile0.00261.7175200.0001
String conversion0.00000.003330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs