Jump to content


Photo

[Snippet] RSS FEED


  • Please log in to reply
32 replies to this topic

#1 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 10 October 2007 - 07:15 AM

File Name: RSS FEED
File Submitter: Cris D.
File Submitted: 10 Oct 2007
File Updated: 18 Jan 2008
File Category: Blogs & News

Module: RSS FEED
Snippet: RSS V2.2
Template: rssTemplate
Author: Cris D
Date: 2007/11/10
Use: This snippet creates a validated RSS xml document that lets users create live links to selected pages in your site

Instructions:
1) Create a template with the template code following...
2) Create and publish a new page (uncached) with the rssTemplate called rssFeed.
3) In the rssFeed page under the publishing tab set content type: "text/xml".
4) Call this snippet in the rssFeed page uncached [!rssFeed2.0!]
5) Eto 1.6.0+Set in the index.php: $etoNotice=false Eto 1.0+ set in manager config Display Linkback-Off.
6) Configure the snippet as per in-snippet documentation
7) Create a link (rss image or hyperlink) to the document rssFeed In a compatible browser, the user will be prompted to "bookmark the feeds" or "subscribe to this feed".

Create a template with the following code:
<?xml version="1.0"  encoding="[(etomite_charset)]"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
[*content*]
</channel>
</rss>
Save it as "rssTemplate"


A word about cached snippets on linked pages: If your RSS feed snippet is called [[cached]] and you have a single [!uncached!] snippet on the linked page, just the page title is returned. If your RSS feed is called [!uncached!] and you have [!uncached!] snippets on the linked page, the snippet call is displayed and the rest of the page is also shown (including evaluated [[cached]] snippets).

Therefore, for best results use this snippet [!uncached!] and all snippets on linked pages [[cached]] unless you have good reason to do otherwise.


Changelog:
V1.3 Updated 2007/11/06
  • Made changes so the feed validates
  • Added Atom namespace to template
  • Now calling site keywords to fill <content> element
  • WebMaster (real name) now must be hard coded
  • RFF882 publishing date set by default
  • isPermaLink case error fixed
  • $feedLink now using makeURL instead of $GLOBALS['www_base_path']
RSSFeedV2.0 2007/11/10
  • Built a simple etomite parser that displays the results of cached snippets on linked pages.
  • Changed the installation from a snippet call in the template, to the snippet call on the page being used as the feed link.
  • You can now set a parent folder for all children to include or set individual pages
  • Added an Etomite notice to the bottom of the feed.

RSSFeed 2.1 2007/11/10
  • Updated content with <![CDATA[]]> attribute
  • Removed htmlentities (not required with CDATA declaration)
  • Fixed unvalidating etoNotice

RSSFeed2.2 2008/01/18
  • Added the capability to read a feed page identified by placing RSS or rss in the documents' keyword
  • Note: If RSS is found on a single page, the $itemLinks and $parent configuration methods are now ignored.
  • Implemented Jim Browski's $blogLinkId suggestion as a html site anchor.


For a good guide to the configurable elements used in this snippet (and more that you can add), see... http://cyber.law.har...du/rss/rss.html

For more assistance, see the in-snippet documentation.

See it in action

Click here to download this file

Edited by Cris D., 04 December 2008 - 08:20 AM.


#2 Jim Browski

Jim Browski

    Likes Etomite Forums!

  • Member
  • PipPip
  • 163 posts

Posted 05 November 2007 - 09:02 PM

This snippet creates an RSS2.0 , xml 1.0 document ...

I checked your demo feed at http://www.artimental.com/rssFeeds.html with some feed validators. They do not seem to be standard-compliant. Beside some mime type issues (which are negligible) there is a problem with the use of the "isPermalink"-Attribute.

See the validation results at
Validome
Feed Validator

#3 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 05 November 2007 - 10:40 PM

Thanks, I didn't know that there was a feed validator (I must admit, I never looked). The guid validation problem is a simple Case issue: isPermalink should be isPermaLink. I'll review it and update the snippet. Thanks for the feedback.

#4 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 06 November 2007 - 10:18 AM

Snippet updated with several improvements including: support for Atom, site Keywords for <content>, now a validating RSS feed.

#5 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 07 November 2007 - 05:00 AM

Just realised that etomite has a automatic character encoding feature:
[(etomite_charset)] will automatically get the correct encoding from the database when placed in the template for this snippet:
<?xml version="1.0"  encoding="[(etomite_charset)]"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
[!rssContent!]
</channel>
</rss>

Edited by Cris D., 07 November 2007 - 07:43 AM.


#6 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 November 2007 - 03:10 PM

Hi Chris,
I've been toying with the idea of using RSS on galleries, but information needed seemed to be spread all over the web, with lots of different standards.
Is there any particular reason you've chosen the Atom namespace rather than an RSS namespace?

Also, is there a reason for creating a template that contains everything, and using a completely empty document? (I'd want some stuff parameterised, otherwise I'd have to create several different templates. (I don't want to create just a single feed for a whole site)

#7 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 08 November 2007 - 08:27 PM

Hi mikef,
Adding the Atom namespace makes is compatible with more aggregators (it does not exclude others by having it there). It is also RSS2.0. This was a recommendations by veridome validator which W3C validator did not object to.

In terms of having the empty content page, this was to have complete control over the output from the snippet and make installation (and snippet authoring) easier. As long as the mime type is set to text/xml in the page the tempate can have [*content*] and the snippet can be on that page. Doing this and adding tweaks to the snippet to let you add snippet calls will let you do pretty much whatever you want for your feed for individual pages.

This snippet does NOT automatically feed every page in the site, it only adds pages that you explicitly add to the config settings in the snippet. However, it would not be that hard to spit out every page automatically if that was required by someone.

I'm still in the process of getting a feed going (will be the next version) that will evaluate all snippets instead of only cached snippets 1 level deep. This will probably be the main issue with using this RSS Feed snippet on your sites: because of images (and info) being displayed by nested snippets.

Edited by Cris D., 08 November 2007 - 08:45 PM.


#8 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 November 2007 - 09:19 PM

Thanks Cris - I'll use atoms if possible then!
I'm not planning to use your snippet, as I don't want the feed to be which pages have changed - thats very complex to determine on my sites (where most pages are made almost entirely from snippet calls) and many pages have multiple presentations depending on parameters in the URL.
What I want to do is generate feeds for:
new artworks on the site as a whole, with the links going to the sub page for the specific artwork
new artworks for specific artworks, with links again going to the specific artwork

I'll probably end up pinching a lot from your snippet, but the end result will only be usable with etogal galleries (and, if at all possible, will use etogalthumb.

the biggest potential problem is if the Atom and/or RSS DTDs require a date for each item, as etogal doesn't store creation date. Its years since I last had to read a DTD!

#9 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 08 November 2007 - 10:38 PM

You might like to read this: RSS2.0 only REQUIRES title, description and link. Everything else (including date) is optional. By setting the TTL (time to live) the page in the feed is automatically refreshed. This will include new pictures if added in that time. Cached snippets will work in the feed. What you are describing is definately do-able.

#10 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 November 2007 - 11:02 PM

Agreed, looks definitely doable. Expect something over the weekend. Thanks Cris!

#11 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 09 November 2007 - 02:48 PM

Snippet updated with a mini-parser that shows cached snippet content in the feeds. Also added the ability to set a feed 'parent' Added an etoNotice to the feed output. Also changed the template and snippet to work together so that the temlpate calls the [*content*] instead of the [!snippet!] to avoid confusion and assist in parsing levels.

#12 Jim Browski

Jim Browski

    Likes Etomite Forums!

  • Member
  • PipPip
  • 163 posts

Posted 12 November 2007 - 04:24 PM

Snippet updated with several improvements including: support for Atom, site Keywords for <content>, now a validating RSS feed.

Thank you very much!
Now it even validates as a RSS 2.0 Feed using the very strict validator at validome.org: Check!

As a validation- and standards-junkie i'm very happy now :D

JB.

#13 Jim Browski

Jim Browski

    Likes Etomite Forums!

  • Member
  • PipPip
  • 163 posts

Posted 12 November 2007 - 04:54 PM

Adding the Atom namespace makes is compatible with more aggregators (it does not exclude others by having it there). It is also RSS2.0. This was a recommendations by veridome validator which W3C validator did not object to.

Playing around with this snippet and Google Reader i encountered a behaviour that might not be intented.

The <atom:link> and <link> element both use the url generated by etomite depending on the Feed-ID. The Google Reader creates a clickable heading for a feed depending on <link>, so if you click on that heading, you are redirected to the rss feed output. I think it would be better to be redirected to an html-overview (think of the startpage of a blog). This is how most blogs output their feeds.

The described behaviour is easy to archive. I propose the following:

1. Add a new parameter "blogLinkId" in the header variables like this
$feedLinkId='13'; // Set to the page id of the published page using the rss template.
$blogLinkId='26'; // Set to the page id of a html-entry-overview (e.g. your Blog-Homepage).
2. Let etomite generate an url for the blogLinkId:
$feedLink=$etomite->makeURL($feedLinkId,'','');
$blogLink=$etomite->makeURL($blogLinkId,'','');
3. Change use of variables in the rss header like this:
<atom:link href="$feedLink" rel="self" type="application/rss+xml" />
<link>$blogLink</link>
That's it.
BTW, did i say that your snippet is great? :D

#14 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 17 January 2008 - 04:52 PM

Snippet updated with this recommendation for a $blogLinkId, thanks for the idea Jim.

Also updated with the ability to place "rss" or "RSS" into a document's keyword where it will now be picked up and automatically added to the feed (at the expense of the folder parent or manual id's...see the snippet documentation for a better explanation). Thanks for the idea Karen.

#15 RobCinOz

RobCinOz

    Etomite Forum Newbie

  • Member
  • 20 posts

Posted 24 February 2008 - 01:13 PM

I'd like to link RSS FEED to a directory (assets/podcasts) to podcast mp3 files of guest speakers that my client records. Then I can delegate the uploading of the mp3 files to someone that does not have manager access (the man that does the recording). I'll use the "FrontEndFileManager" snippet to allow the uploads.

1. Can this be done (linking to directory)?

2. How?

#16 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 24 February 2008 - 09:25 PM

Once you start looking at streaming content you open up a whole new array of potential problems,(buffering, timeouts etc). Yes it could be done but if the current code works with it it would be lucky.

#17 cathode

cathode

    Loves Etomite Forums!

  • Staff
  • 663 posts

Posted 26 February 2008 - 11:54 PM

Cris,
I've set up this snippet and it works great, but I have some questions:

1) Is there a right way of disabling the etoNotice? I'm not finding this switch in the index file... Also wouldn't it be nice not to have to do this? I'd like to keep the notice but not have it show up in the feed...
2) how can I call this snippet dynamically (if possible) so that a feed of the page it's clicked on is available? Let me elaborate: I'm on the news page, I click the RSS link, and I get a feed of the news page. I'm on the home page, I click the RSS link, and I get a feed of the home page.

Also, can I use a parent of '0' to get a feed of the whole website?
thanks :) Great work as usual.

#18 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 27 February 2008 - 04:59 AM

I'm on the news page, I click the RSS link, and I get a feed of the news page. I'm on the home page, I click the RSS link, and I get a feed of the home page.

That's a good Idea, I'll have a look at the code and see what I can do, I never thought of that but it is an obvious use...

No you can't set 0 to do the whole site. You can, however use phpMyAdmin to add 'rss' to every page in the keyword table, this will add every page in the site.

Eto notice needs to be manually removed by deleting it from the bottom of the snippet. I thought that seeing I was asking everyone to remove the notice from thier site for the feed to validate, that they should have it somewhere and made it tricky for people to remove it to compensate.

I'll get back to you about possibilities for adding a dynamic rss feed link to embed in a template.

[edit] the etoNotice=false; switch is almost at the bottom of the index.php file, if it still exists, you will get an error with the feed. If you have already removed it as mentioned above and you are seeing it in the feed, you will have to remove it from the snippet code.[/edit]

Edited by Cris D., 27 February 2008 - 07:38 AM.


#19 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 27 February 2008 - 08:14 AM

OK, I can adapt the snippet to create a link for the page being viewed as a single page, however, it will mean a new snippet. There are too many checks and balances in the existing RSS2.2 snippet to add this feature easily. It would be much easier to re-code it as a stand-alone RSSThisPage snippet. So this brings us to how badly do you need this feature? I'm pretty bogged down in my current project unless someone else want to do it:
  • remove all checks for input types and just use a $_POST['rssId'];
  • configure the new snippet to return the results of the posting page only,
  • code the data so only the posting page data is shown($data=$etomite->getDocumentContent($_POST['rssId']);)
  • create a new document for just the RSSThisPage snippet
  • create a form that posts the $etomite->documentIdentifier id to the snippet to place in the site template,
  • test to see how the 2 rss snippets will interact if in the same site
  • document setting up procedures for the RSSThisPage snippet
  • Post to etomite library.

Any takers? Otherwise as much as I love supporting my snippets, it won't be until nearing the end of this year...

#20 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 28 February 2008 - 11:41 AM

Strike that last comment from the record your honour... In my defence, I was tired, cranky and stressed. I wrote the rssThisPage snippet and i'm the process of posting it to the snippet library... enjoy.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users