Welcome Guest, Not a member yet? Register   Sign In
RSS Question
#3

[eluser]adamfairholm[/eluser]
Yes, here is the code generating the rss feed:

Code:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "
";
?>

<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:c>

    <channel>
    
    &lt;title&gt;&lt;?php echo $feed_name; ?&gt;&lt;/title&gt;
    &lt;link&gt;&lt;?php echo $feed_url; ?&gt;&lt;/link&gt;
    <description>&lt;?php echo $page_description; ?&gt;</description>
    <pubDate>&lt;?php echo rss_date_format($last_date);?&gt;</pubDate>
    <lastBuildDate>&lt;?php echo rss_date_format($last_date);?&gt;</lastBuildDate>
    <language>&lt;?php echo $page_language; ?&gt;</language>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <managingEditor>&lt;?php echo $creator_email; ?&gt;</managingEditor>

    <dc:rights>Copyright &lt;?php echo gmdate("Y", time()); ?&gt;</dc:rights>
    <a>

    &lt;?php foreach($posts->result() as $entry): ?&gt;
    
        <item>

          &lt;title&gt;&lt;?php echo xml_convert($entry->title); ?&gt;&lt;/title&gt;
          &lt;link&gt;&lt;?php echo $this->config->item('link_url').$type."/entry/".$entry->id ?&gt;&lt;/link&gt;
          <guid>&lt;?php echo $this->config->item('link_url').$type."/entry/".$entry->id ?&gt;</guid>

          <description>&lt;![CDATA[
      &lt;?=$entry->body;?&gt;
      ]]></description>
      <pubDate>&lt;?=rss_date_format($entry->created_on)?&gt;</pubDate>
        </item>
        
    &lt;?php endforeach; ?&gt;
    
    </channel></rss>

And here is the code generating the atom feed:

Code:
&lt;?php
echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;' . "
";
?&gt;

<feed >

&lt;title&gt;&lt;?=$feed_name;?&gt;&lt;/title&gt;
<subtitle>&lt;?=$page_description;?&gt;</subtitle>
&lt;link href="http://www.ceosforcities.org/&lt;?=$type;?&gt;" rel="self"/&gt;
&lt;link href="http://ceosforcities.org/"/&gt;
<updated>&lt;?=atom_date($last_date);?&gt;</updated>
<a>
   <name>CEOs For Cities</name>
   <email>&lt;?=$creator_email;?&gt;</email>
</author>
<id>&lt;?php if($type=="blog"){ ?&gt;tag:www-ceosforcities-org,2008:/conversations/blog//1&lt;?php }else{?&gt;tag:www-ceosforcities-org,2008:/&lt;?=$type;?&gt;&lt;?php } ?&gt;</id>



    &lt;?php foreach($posts->result() as $entry): ?&gt;

<entry>

   &lt;title&gt;&lt;?=$entry->title;?&gt;&lt;/title&gt;

    &lt;link rel="alternate" type="text/html" href="&lt;?php echo $this-&gt;config->item('link_url').$type."/entry/".$entry->id ?&gt;" />
    &lt;link rel="service.edit" type="application/atom+xml" href="&lt;?php echo $this-&gt;config->item('link_url').$type."/entry/".$entry->id ?&gt;" title="&lt;?=$entry->title;?&gt;" />

  
   <id>&lt;?php if($entry->entry_atom_id){ echo $entry->entry_atom_id;} else{?&gt;tag:www.ceosforcities.org,&lt;?=dashes($entry->created_on);?&gt;:/&lt;?=$type;?&gt;/entry/&lt;?=$entry->id;?&gt;&lt;?php } ?&gt;</id>
  
   <published>&lt;?=atom_date($entry->created_on);?&gt;</published>
   <updated>&lt;?=atom_date($entry->created_on);?&gt;</updated>
  
   <summary>&lt;![CDATA[&lt;?=strip_tags(word_limiter($entry->body, 100));?&gt;]]></summary>
   <a>
       <name>CEOs for Cities</name>
       <uri>http://www.ceosforcities.org</uri>
   </author>
   <content type="html" xml:lang="en" xml:base="http://www.ceosforcities.org/conversations/blog/">
        &lt;![CDATA[&lt;?=$entry->body;?&gt;]]>
   </content>
</entry>

    &lt;?php endforeach; ?&gt;

</feed>

atom_date, rss_date_format, and dashes are just formatting a the date from a datetime stamp. The output validates, and you can see that in the Atom/RSS feed output I linked to above.

The atom feed is also designed to smoothly work with the old one, hence some maneuvering around to keep old atom ids.


Messages In This Thread
RSS Question - by El Forum - 06-29-2008, 09:48 PM
RSS Question - by El Forum - 06-30-2008, 12:27 AM
RSS Question - by El Forum - 06-30-2008, 12:39 AM
RSS Question - by El Forum - 06-30-2008, 12:46 AM
RSS Question - by El Forum - 06-30-2008, 07:10 AM
RSS Question - by El Forum - 06-30-2008, 10:03 AM
RSS Question - by El Forum - 08-19-2008, 05:25 AM
RSS Question - by El Forum - 08-19-2008, 09:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB