Welcome Guest, Not a member yet? Register   Sign In
formatting rss output
#1

[eluser]Future Webs[/eluser]
Hi all,

Ive been setting up some rss feeds for a site im developing but came across an issue.

I followed dereks post on how to build a simple feed and got that working fine.

The problem is the content that is shown when i subscribe to the feed using my reader (thunderbird). At the moment i see the full page of the blog post that the feed refers to. This includes the header, footer, menus, comments etc.

What I would like to happen is that when i view the feed in my reader it only shows the post itself or even a summary with an image and have the user visit the site to view the full thing.

an example would be how the feeds look on something like TechCrunch

Im sure its something obvious but Im new to creating feeds

Heres a link to dereks post if your not familiar with the code

http://derekallard.com/blog/post/buildin...e-igniter/
#2

[eluser]Michael Wales[/eluser]
A feed is nothing more than a view - rather than following the normal HTML/xHTML spec you just follow the RSS spec (and pass a few different headers).

So if header/footer/menu/comment/etc are being displayed in your feed - it's because you are pushing that out to your view. Stop sending that data to your view and it will stop existing in your feed.
#3

[eluser]Future Webs[/eluser]
so i would make a seperate view just for the feed ?

is the view not taken from this part of the feed loop

Code:
<link><?php echo site_url('/blog/detail/'.$row->blog_detail_id) ?></link>


if so would we not be sending the reader to that stripped down version when they click to view the page on our site ?

another example would be any of the tuts sites feeds .. NetTuts, PsdTuts etc
#4

[eluser]GSV Sleeper Service[/eluser]
[quote author="w3bm" date="1232588211"]so i would make a seperate view just for the feed ?[/quote]
yes, you need to make a separate view for the feed.

[quote author="w3bm" date="1232588211"]is the view not taken from this part of the feed loop

Code:
<link><?php echo site_url('/blog/detail/'.$row->blog_detail_id) ?></link>
[/quote]
no, that will link back to your original article.

[quote author="w3bm" date="1232588211"]
if so would we not be sending the reader to that stripped down version when they click to view the page on our site ?[/quote]
no, your feed will live in a different method in your blog controller.
eg
http://domain.com/blog/detail/99 - direct link to your blog entry ('detail' method)
http://domain.com/blog/rss - people will subscribe to your feed using this URI

to let your users know that you've got a feed, you'll need to add a line like this to head section of your HTML
Code:
<link  href="http://domain.com/blog/rss" rel="alternate" type="application/rss+xml" title="RSS" />
#5

[eluser]Future Webs[/eluser]
hi gsv,

yeh i have the feed all set up and working ok at its own url for different aspects of the site and can view the basic feed info in the browser and then use this url to subscribe to the feed with my reader.

The problem is what is shown in my reader (thunderbird) when i view each post

instead of showing the whole site with that pages content (just as you would view online) I want to see a stripped down version and then be able to click through to view the full thing

I also sussed the adding a bit in the header to give a quick subscribe link within the url bar of the browser
#6

[eluser]GSV Sleeper Service[/eluser]
is your site online? post the link to your feed.
#7

[eluser]Future Webs[/eluser]
[quote author="GSV Sleeper Service" date="1232590914"]is your site online? post the link to your feed.[/quote]

Im afraid its under lock and key at the mo so I cant post any links to it.

Heres a site that does exactly what mine does at the mo and is a codeigniter site so im guessing uses a similar approach

http://www.logogala.com/

And heres one that does it just how I want it to work

http://nettuts.com/
#8

[eluser]Michael Wales[/eluser]
Okay, let's say this is your normal HTML web browser view - we're loading a header and footer dynamically here:

Code:
<?php $this->load->view('header'); ?>
<?php foreach ($article as $a): ?>
  <div class="entry">
    <h3>&lt;?php echo $a->title; ?&gt;</h3>
    &lt;?php echo $a->excerpt; ?&gt;
  </div>
&lt;?php endforeach; ?&gt;
&lt;?php $this->load->view('footer'); ?&gt;

This would be the View for your RSS feed:
Code:
&lt;?php echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;' . "\n";?&gt;
<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:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    &lt;title&gt;My Feed&lt;/title&gt;
    &lt;link&gt;&lt;?php echo site_url('rss'); ?&gt;&lt;/link&gt;
    <description>Whatever</description>
    // More stuff here - this is all very basic RSS Spec

    &lt;?php echo foreach ($article as $a): ?&gt;
      <item>
        &lt;title&gt;&lt;?php echo $a->title; ?&gt;&lt;/title&gt;
        &lt;link&gt;&lt;?php echo site_url(url_title($a->title)); ?&gt;&lt;/link&gt;
        <guid>&lt;?php echo site_url(url_title($a->title)); ?&gt;</guid>
        <description>&lt;![CDATA[
           &lt;?php echo $a->excerpt; ?&gt;
        ]]></description>    
        <pubDate>&lt;?php echo date ('r', $a->post_date);?&gt;</pubDate>
      </item>
    &lt;?php endforeach; ?&gt;
</channel>
</rss>

As you can see - it's nothing more than another View. It will do exactly what you tell it to do - if you tell it to place a header in there, it's going to. If you don't (like I did not in the example above), it won't.

Nothing special about Views - Views aren't defined as xHTML & CSS - a view is nothing more than a visual representation of data. It could be JSON, XML, xHTML, ActionScript - whatever you want.
#9

[eluser]Future Webs[/eluser]
hi guys,

I think were talking at cross purposes here.

The feed when viewed in the browser works fine.

It has its own controller and view etc and works just right.

Its pretty much just as you have it there

The only problem i have it when i download the items to my rss reader which in this case is my mail client thunderbird. Each article shows the whole site in my reader where as i would like to just show a summary and maybe an image
#10

[eluser]Michael Wales[/eluser]
Are you sure Thunderbird is using the Feed Address - do you have an autodiscovery tag?

For instance, if your Feed is example.com/feed and your domain is example.com:
You go into Thunderbird and just enter example.com, Thunderbird *may* not be able to find the feed automatically and just run it's own sort of "check for changes" type system - a ghetto feed if you will.

I would do the following:
A) Check to make sure Thunderbird is pointed at your feed, not the domain itself.
B) Make sure you have an autodiscovery tag (&lt;link rel="alternate" ... /&gtWink
C) Subscribe through another service, Google Reader, and see if your feed is displaying correctly.
D) Review the RSS 2.0 spec and ensure you are meeting all of it's rules. Derek's example may not be up to date.




Theme © iAndrew 2016 - Forum software by © MyBB