RSS2HTML PHP Script Documentation v3.x Contents Introduction Uses Quick Start Templates Running from FeedForAll's server Running on local server Example websites Advanced Notes Restricting Access Caching Introduction: ------------- FeedForAll has made available a free PHP program called rss2html.php, which can be used by webmasters to automatically display RSS feeds on their website. The resulting webpage will always show the RSS feed's most current data. The advantage of using the rss2html.php script is that the resulting webpage's contents will always be up to date, and can be easily spidered by search engines. Uses: ----- - Create a webpage with an RSS feed's information - Insert an RSS feed's information into a location in an existing webpage Quick Start: ------------ rss2html.php has a built in utility to help get started quickly. This is done by calling rss2html.php with the parameter "buildURL", for example http://scripts.rss2html.com/public/rss2html.php?buildURL . After filling in the infomation about your feed and template you will be shown the exact code to include the output of rss2html.php into a webpage. Templates: ---------- FeedForAll's rss2html.php script uses templates to generate its output. The templates allow you to easily control what the resulting webpage will look like. A template can be used to generate a complete webpage, or a portion of a webpage like a table (which can then be included inside an existing webpage). The template's syntax is exactly the same as the syntax used in FeedForAll's export functions. Templates are simply standard HTML documents, with special variables inserted where the RSS feed's data should appear. Usually the easiest way to create a template is to create a sample webpage with some real data in it, and then replace the feed's data with template variables, or modify an existing webpage, by adding template variables. Here is a list of the variables supported by FeedForAll's rss2html.php script: ~~~FeedTitle~~~ (The feed's title) ~~~FeedDescription~~~ (the feed's description) ~~~FeedContentEncoded~~~ (the feed's description from optional ContentEncoded field) ~~~FeedLink~~~ (the feed's link) ~~~FeedPubDate~~~ (the feed's pub date/time in RSS format) ~~~FeedPubLongDate~~~ (the feed's date in a long date format) ~~~FeedPubShortDate~~~ (the feed's date in a short date format) ~~~FeedPubLongTime~~~ (the feed's time in a long time format) ~~~FeedPubShortTime~~~ (the feed's time in a short time format) ~~~FeedCreativeCommons~~~ (the feed's Creative Commons(R) License URL if one exists) ~~~FeedImageUrl~~~ (the URL to the feed's image) ~~~FeedImageTitle~~~ (the title for the feed's image) ~~~FeedImageLink~~~ (the link associated with the feed's image) ~~~FeedMaxItems=X~~~ (the maximum number of items to appear on the webpage - replace 'X' with a number. The first 'X' number of items in the feed will be displayed. Using a negative number for 'X' will show the last 'X' items from a feed. ~~~SortByPubDate~~~ (the items will be sorted by their PubDate, before they are displayed - newest first) ~~~NoFutureItems~~~ (items with PubDates that are in the future won't be displayed until that date/time arrives) ~~~BeginItemsRecord~~~ (repeat everything between this and the end marker, for each item) ~~~EndItemsRecord~~~ (repeat everything between this and the start marker, for each item) ~~~BeginAlternateItemsRecord~~~ (separates the ItemsRecord into alternating halves) ~~~ItemTitle~~~ (the item's title) ~~~ItemDescription~~~ (the item's description) ~~~ItemContentEncoded~~~ (the item's description from optional ContentEncoded field) ~~~ItemLink~~~ (the item's link) ~~~ItemPubDate~~~ (the item's pub date/time in RSS format) ~~~ItemPubLongDate~~~ (the items's date in a long date format) ~~~ItemPubShortDate~~~ (the item's date in a short date format) ~~~ItemPubLongTime~~~ (the item's time in a long time format) ~~~ItemPubShortTime~~~ (the item's time in a short time format) ~~~ItemEnclosureUrl~~~ (the item's enclosure URL) ~~~ItemEnclosureType~~~ (the item's enclosure MIME type) ~~~ItemEnclosureLength~~~ (the item's enclosure Length) ~~~ItemEnclosureLengthFormatted~~~ (the item's enclosure Length formatted into Kilo, Mega or Giga Bytes) ~~~ItemGuid~~~ (the item's GUID field value) ~~~ItemAuthor~~~ (the item's author field value) ~~~ItemComments~~~ (the item's comments field value) ~~~ItemSource~~~ (the item's source field value) ~~~ItemSourceUrl~~~ (the item's source url attribute value) ~~~ItemCategory~~~ (the first item's category field value) ~~~ItemCategoryDomain~~~ (the item's first category domain attribute value) ~~~ItemCreativeCommons~~~ (The Creative Commons(R) License URL of the item, or feed if there isn't one on the item but there is on the feed) When the rss2html.php script runs, it will substitute information from the RSS feed into the location wherever a variable is found. For example, every time ~~~FeedTitle~~~ is found in the template's text, the Title from the RSS feed will be substituted. Special variables: The ~~~FeedXMLFilename~~~ variable is the URL of the feed being processed. The ~~~FeedMaxItems=X~~~ variable can be used to limit the number of items that will be inserted into the webpage. Replace the 'X' with a number of feed items you would like displayed (no spaces). The ~~~NumberOfFeedItems~~~ variable is the acutally number of items that were found and will be displayed, before any advanced processing. The ~~~BeginItemsRecord~~~ is used to mark the beginning of the section in the template, that should be repeated for each item in the RSS feed. A corresponding ~~~EndItemsRecord~~~ should be used to mark the end of the repeating section. Everything invbetween these two variables will be repeated for every item in the feed. You would typically place all your ~~~Item...~~~ variables in between the ~~~BeginItemsRecord~~~ and ~~~EndItemsRecord~~~ variables. The ~~~BeginAlternateItemsRecord~~~ tag is optional, and can be used in between the ~~~BeginItemsRecord~~~ and ~~~EndItemsRecord~~~ variables to split the section into two halves. Everything between the ~~~BeginItemsRecord~~~ and the ~~~BeginAlternateItemsRecord~~~ will be used for odd numbered RSS feed items, and everything between the ~~~BeginAlternateItemsRecord~~~ and the ~~~EndItemsRecord~~~ will be used for even numbered RSS feed items. This is typically used to give alternating feed items a slightly different look. Example - template used to generate a complete HTML webpage:
~~~ItemTitle~~~ |
~~~ItemDescription~~~ |
|
~~~ItemPubShortDate~~~ ~~~ItemTitle~~~ ~~~ItemDescription~~~ more info |