Forums / General / Urgent - Change the date on RSS (exported feed)

Urgent - Change the date on RSS (exported feed)

Author Message

Greg Sanderson

Thursday 24 April 2008 4:40:36 am

Hi

I have kind of an urgent problem which I hope someone can help with. I have created an RSS feed to publish the latest news from my eZ site. This works however the items are sorted by their node publish date, rather than the publish date the user enters in a date field when they are creating the node.

Can anyone tell me where the XML that is the RSS feed is generated, and how to change it so that instead of using the eZ date it instead uses the date and time field from the node's data map to sort and display?

Thank you

Carlos Revillo

Thursday 24 April 2008 5:00:44 am

Hi.

My reply is for eZ4, but i don't think it would be much different in previous versions

you will find it at kernel/classes/ezrssexportitem.php

There you can search for this function

static function fetchNodeList( $rssSources, $objectListFilter )

In that function you'll find

$listParams = array( 'Limit' => $objectListFilter['number_of_objects'],
                                 'SortBy' => array( 'published', false )
                                );

You can change "SortBy" there.

Anyway, this is only a hack. I prefer not to hack ezpublish kernel clasess. Maybe i would do an extensions (Basically copying this classes) and so, you will no have problems if you want to upgrade ez in the future.

Hope it helps.

Greg Sanderson

Thursday 24 April 2008 5:23:11 am

Thanks - that should change the sort method but the published date and time will still appear on the RSS feed, even if they are in a different order. Is there a way to access the data_map like you would do $node.object.data_map or something in normal templates? That way the date could be shown instead of the attribute called published..

Carlos Revillo

Thursday 24 April 2008 5:34:27 am

For this you will have to look at kernel/classes/ezrssexport.php

I suppose you're working with RSS 2.0 and not with RSS 1.0

So, you will have to look for fetchRSS2_0 function

there you will find

unset( $itemPubDate );
            $itemPubDate = $doc->createElement( 'pubDate', gmdate( 'D, d M Y H:i:s', $object->attribute( 'published' ) ) .' GMT' );

$object->attribute('published') is the date "printed" in the rss content.
you can change it to

 $dataMap = $object->dataMap();
  

and get the content of that field.

Greg Sanderson

Thursday 24 April 2008 5:57:13 am

Awesome - it is almost working. Thank you for your help so far. The items are now being sorted correctly but now there is a blank space where the date and time should be on the RSS feed (it is v2).

I have added this code:

$datamap = $object->dataMap();
// get the data_map of the object in order to access its publish date attribute

$publishdate = $datamap.publish_date.content.timestamp;
// the publish date the user entered as a timestamp

$itemPubDate = $doc->createElement( 'pubDate', gmdate( 'D, d M Y H:i', $publishdate|datetime ) .' GMT' );

... and commented out the $itemPubDate line that was there before. The items are now sorted correctly but the date and time is not shown. Am I accessing the time correctly? It is called publish_date.

Carlos Revillo

Thursday 24 April 2008 6:49:27 am

remember you're working now with php code. you cannot think the thinks you do in templates to get content work the same.
i mean, you'll get nothing in php if you use $dataMap.publish_date...

$dataMap is an array, so, for the fields you will have to ask for $dataMap["field"]

So, your code should be like

$dataMap = $object->dataMap(); // this is an array
$publish_date = $dataMap["publish_date"]->content() // this will result a ezdate object
$timestamp = $publish_date->timeStamp();
//and finally
$itemPubDate = $doc->createElement( 'pubDate', gmdate( 'D, d M Y H:i:s', $timestamp ) .' GMT' );

Greg Sanderson

Thursday 24 April 2008 7:05:19 am

Oh of course!

A very, very big thank you. That code works and the RSS now works perfectly.

Thank you!

eZ debug

Timing: Jan 18 2025 05:07:04
Script start
Timing: Jan 18 2025 05:07:04
Module start 'content'
Timing: Jan 18 2025 05:07:04
Module end 'content'
Timing: Jan 18 2025 05:07:04
Script end

Main resources:

Total runtime0.7826 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.9531180.8203
Module start 'content' 0.00480.6042 769.7734526.7031
Module end 'content' 0.60900.1735 1,296.4766337.7891
Script end 0.7825  1,634.2656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.5054210.0002
Check MTime0.00150.1892210.0001
Mysql Total
Database connection0.00070.086510.0007
Mysqli_queries0.697089.06712060.0034
Looping result0.00190.24892040.0000
Template Total0.753496.320.3767
Template load0.00190.239720.0009
Template processing0.751596.032520.3758
Template load and register function0.00020.026210.0002
states
state_id_array0.00090.118710.0009
state_identifier_array0.00100.128320.0005
Override
Cache load0.00160.2001490.0000
Sytem overhead
Fetch class attribute can translate value0.00180.236130.0006
Fetch class attribute name0.00130.160370.0002
XML
Image XML parsing0.00050.062930.0002
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00610.7851210.0003
String conversion0.00000.000530.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs