Need to Add pubdate to an rss.php file

Permalink
Using the 'Simple News' addon for a site I designed. I am integrating the site with Facebook so when news items are added it appears automatically on the Fan page of the site's Facebook page. However, the rss.php file does not have a <pubdate> value. I need to add the <pubdate> value to this rss.php file... Can anyone help??

<?php     
defined('C5_EXECUTE') or die(_("Access Denied."));
$site = 'http://'.$_SERVER["SERVER_NAME"];
      function translateFrom($text) {
         // old stuff. Can remove in a later version.
         $text = str_replace('href="{[CCM:BASE_URL]}', 'href="' . BASE_URL . DIR_REL, $text);
         $text = str_replace('src="{[CCM:REL_DIR_FILES_UPLOADED]}', 'src="' . BASE_URL . REL_DIR_FILES_UPLOADED, $text);
         // we have the second one below with the backslash due to a screwup in the
         // 5.1 release. Can remove in a later version.
         $text = preg_replace(
            array(
               '/{\[CCM:BASE_URL\]}/i',
               '/{CCM:BASE_URL}/i'),
            array(
               BASE_URL . DIR_REL,

Cyberdave
 
dwayneparton replied on at Permalink Reply
dwayneparton
If you haven't got help on this yet. You might try to talk with Chad:
http://www.concrete5.org/marketplace/addons/simple-news/...
Submit a support ticket and he should respond fairly soon.

Just at an initial glance I would think that you needed to do something like this:
$row=$r->FetchRow();
               $feed = '<item>';
               $feed .= '<title>'.$row['title'].'</title>';
               $feed .= '<link>'.$site.View::url(getBlockPath($cParentID)).'index.php?cID='.$row['cParentID'].'</link>';
               $feed .= '<description>'.htmlspecialchars(strip_tags($row['content'])).'</description>';
               //This is the added modification for pubdate
               //Get the pubdate according to the cID   
               $cobj = $row['cParentID'];
               $pubdate = date( 'D, d M Y H:i:s T',strtotime($cobj->getCollectionDatePublic()));
               //Get the PubDate
               $feed .= '<pubDate>'.$pub_date.'</pubDate>';
               //End of modification
               $feed .='</item>';
               echo str_replace($strip,$rplace,$feed);
            }


This is only a guess, you can try it. But I think the best bet you have is asking the Chad.
Hope this helps.
Cyberdave replied on at Permalink Reply
Cyberdave
Yeah. I've submitted a Support form.

In the meantime, I have edited that section of code to this:

$row=$r->FetchRow();
               $feed = '<item>';
               $feed .= '<title>'.$row['title'].'</title>';
               $feed .= '<link>'.'http://www.websiteaddress.com/index.php?cID=69'.'</link>';
               $feed .= '<description>'.htmlspecialchars(strip_tags($row['content'])).'</description>';
               $feed .= '<language>en-gb</language>';
               $feed .= '<pubDate>'.date('D, d M Y H:i:s O').'</pubDate>';
               $feed .= '<lastBuildDate>'.date('D, d M Y H:i:s O').'</lastBuildDate>';
               $feed .='</item>';
               echo str_replace($strip,$rplace,$feed);


This gets the Facebook app (RSS Graffiti) to recognise the feed and import it on to the wall, but the pubDate seems to be the same for all items (when I download RSS file), even though they have been created on different dates. Do I need to change the pubDate code to make each one unique?
dwayneparton replied on at Permalink Reply
dwayneparton
Sorry this took so long. I hope you solved this but I just wanted to make sure. Just at initial glance I would say that the pubdate script you are using looks to just get the current date, you need to get the pubdate from each item. It will work, but the info will all be the same and really it won't be accurate as you have noticed. I believe you can use this or something similar and get the pubdate for each item.
$cobj = $row['cParentID'];
$pubdate = date( 'D, d M Y H:i:s T',strtotime($cobj->getCollectionDatePublic()));
$feed .= '<pubDate>'.$pub_date.'</pubDate>';

This says something like create a date string with the items CollectionDatePublic. This is the date stored in the DB for the item. I am shooting from the hip, but you should probably use something similar to this to have well built feed.