<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://simplepie.org/wiki/lib/exe/css.php?s=feed" type="text/css"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>SimplePie tutorial</title>
    <subtitle></subtitle>
    <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/"/>
    <id>http://simplepie.org/wiki/</id>
    <updated>2026-06-20T12:06:54+00:00</updated>
    <generator>FeedCreator 1.7.2-ppt DokuWiki</generator>
<link rel="self" type="application/atom+xml" href="http://simplepie.org/wiki/feed.php" />
    <entry>
        <title>Changing timezones in a timestamp</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/changing_timezones_in_a_timestamp"/>
        <published>2007-05-23T04:57:49+00:00</published>
        <updated>2007-05-23T04:57:49+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/changing_timezones_in_a_timestamp</id>
        <summary>By default PHP's date() function (and in turn, SimplePie's get_date() method) return the timestamp according to the web server's timezone.  But what if your timezone and your server's are different and you want to display yours?

PHP 5.1 or newer

Use the date_default_timezone_set() function with a timezone parameter from the timezone page.  This should be set before PHP's date() or SimplePie's get_date() is called.</summary>
    </entry>
    <entry>
        <title>Flickr Lightbox</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/flickr_lightbox"/>
        <published>2007-08-29T20:15:29+00:00</published>
        <updated>2007-08-29T20:15:29+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/flickr_lightbox</id>
        <summary>Flickr is a popular photo sharing site that supports the best and the brightest ideas that the modern web has to offer.  Lightbox is a relatively popular script that provides a cool looking UI for viewing photos.  Lightbox was so popular, in fact, that it has inspired innumerable spinoffs and variations.  Here is a list of some of the various Lightbox clones.</summary>
    </entry>
    <entry>
        <title>Grab custom tags or attributes</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes"/>
        <published>2007-10-25T00:18:57+00:00</published>
        <updated>2007-10-25T00:18:57+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes</id>
        <summary>SimplePie 1.0 introduces the ability to grab data from any element in the feed, even if there aren't public methods for grabbing them.  This is a popular feature among RSS hackers.

SimplePie maps data by the namespace URL, and from there you can use PHP's print_r() function to navigate the rest of the way through the array.  This example shows you how to get an event's start date from a Google Calendar feed.  Not only will we find this date data, but we'll reformat it and then sort the items ch…</summary>
    </entry>
    <entry>
        <title>How do I get a thumbnail from a YouTube feed?</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_do_i_get_a_thumbnail_from_a_youtube_feed"/>
        <published>2007-06-20T09:21:21+00:00</published>
        <updated>2007-06-20T09:21:21+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_do_i_get_a_thumbnail_from_a_youtube_feed</id>
        <summary>SimplePie 1.0 introduces full support for Media RSS -- a popular set of tags geared for media files, and are added to RSS and Atom feeds.

:!: This tutorial assumes that you're already familiar with using SimplePie, including looping through items.  This is only sample code, and you should not create real pages using the (horrid) HTML generated by this example.</summary>
    </entry>
    <entry>
        <title>How to display a single item in a feed</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_display_a_single_feed_item"/>
        <published>2008-07-18T11:11:23+00:00</published>
        <updated>2008-07-18T11:11:23+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_display_a_single_feed_item</id>
        <summary>How to display a single item in a feed


Basically all you do is check for the presence of an item number field in the url query string. If it's present, just show that item. Here is some demo code:


&lt;?php

require 'simplepie.inc';

$url = 'http://news.google.com/news?ned=us&amp;topic=h&amp;output=rss';

$feed = new SimplePie();
$feed-&gt;set_feed_url($url);
$feed-&gt;init();

// default starting item
$start = 0;

// default number of items to display. 0 = all
$length = 0; 

// if single item, set start to i…</summary>
    </entry>
    <entry>
        <title>This demo shows how to use SimplePie and a flat file database to display previous feed items like Google Reader</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_display_previous_feed_items_like_google_reader"/>
        <published>2008-07-25T18:51:35+00:00</published>
        <updated>2008-07-25T18:51:35+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_display_previous_feed_items_like_google_reader</id>
        <summary>This demo shows how to use SimplePie and a flat file database to display previous feed items like Google Reader


&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;title&gt;Demo of how to use SimplePie and a flat file database to display old feed items&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;


&lt;?php

/*
        This is a demo showing how to use SimplePie and a flat file database to display pre…</summary>
    </entry>
    <entry>
        <title>How to do item paging</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_do_item_paging"/>
        <published>2011-03-06T03:56:52+00:00</published>
        <updated>2011-03-06T03:56:52+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_do_item_paging</id>
        <summary>Although this tutorial doesn't require SimplePie (this is just plain ol' PHP), there have been a few users who have asked for this.  In this tutorial we will merge multiple feeds together, and allow for a variety of paging options (5, 10, or 20 items per page; Previous and Next buttons).</summary>
    </entry>
    <entry>
        <title>How to edit part of the feed before parsing it</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_edit_part_of_the_feed_before_parsing_it"/>
        <published>2007-08-02T22:25:25+00:00</published>
        <updated>2007-08-02T22:25:25+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_edit_part_of_the_feed_before_parsing_it</id>
        <summary>There are instances where for one reason or another, there's an issue with a feed that you need to correct before attempting to parse it.  If you don't control the feed (to make the edits directly), you can still work around these types of issues.

:!: This tutorial assumes that you're already familiar with using SimplePie, including looping through items.  This is only sample code, and you should not create real pages using the (horrid) HTML generated by this example.</summary>
    </entry>
    <entry>
        <title>How to group multiple posts by day</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_group_multiple_posts_by_day"/>
        <published>2007-09-10T18:32:36+00:00</published>
        <updated>2007-09-10T18:32:36+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_group_multiple_posts_by_day</id>
        <summary>For this tutorial, I'll show you how to group posts by date, and inside each of those groups all of the items are sorted by time.

This will ONLY work for feeds where all items have timestamps.  This is NOT 100% reliable because some feeds simply don't have timestamps.</summary>
    </entry>
    <entry>
        <title>Limit the number of items per feed to be used with Multifeeds</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_limit_the_number_of_items_displayed_per_feed_when_using_multifeeds.php"/>
        <published>2008-06-11T06:21:28+00:00</published>
        <updated>2008-06-11T06:21:28+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_limit_the_number_of_items_displayed_per_feed_when_using_multifeeds.php</id>
        <summary>:!: This tutorial is obsolete. Use the set_item_limit() method instead.

In SimplePie 1.0, we simplified the process of merging together multiple feeds, sorting them by date, and displaying them.  This method allows you to do all of the normal SimplePie stuff without requiring you to do any array hacking or anything.  This tutorial will show you how to merge only the first 5 items per feed, and sort those by date and time.</summary>
    </entry>
    <entry>
        <title>How to make description links open in a new window</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_make_description_links_open_in_a_new_window"/>
        <published>2011-03-06T03:56:52+00:00</published>
        <updated>2011-03-06T03:56:52+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_make_description_links_open_in_a_new_window</id>
        <summary>There may be times when you want to open all links from an external feed in a new window.  There are a few things to take into account when doing this:

	*  The best way to target specific HTML tags for modification is by parsing the DOM.  Newer versions of PHP have a DOM extension, but because SimplePie still supports PHP 4.x, SimplePie is not currently built on the PHP DOM extension (SimplePie 2.0 will be, however).  In light of this, the simplest solution would be to use the DOM support in th…</summary>
    </entry>
    <entry>
        <title>NewsBlocks Demo 2.0</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/how_to_replicate_popurls"/>
        <published>2011-02-17T08:14:14+00:00</published>
        <updated>2011-02-17T08:14:14+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/how_to_replicate_popurls</id>
        <summary>Recently, websites like infonary, PopURLs, 1-TM, TheWebList, Miniboxs, and Original Signal have become all the rage.  Generally, these sites consist of multiple feeds -- each it it's own block on the page.  These sites typically consist of a relatively wide range of topics from news to media to technology to whatever else.</summary>
    </entry>
    <entry>
        <title>Only display images from a feed</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/only_display_images_from_a_feed"/>
        <published>2011-03-06T03:56:52+00:00</published>
        <updated>2011-03-06T03:56:52+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/only_display_images_from_a_feed</id>
        <summary>A number of solutions for this were noted at &lt;http://simplepie.org/support/viewtopic.php?id=643&gt;</summary>
    </entry>
    <entry>
        <title>Only display items from the last 24 hours</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/only_display_items_from_the_last_24_hours"/>
        <published>2008-03-12T16:17:33+00:00</published>
        <updated>2008-03-12T16:17:33+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/only_display_items_from_the_last_24_hours</id>
        <summary>This is a pretty simple way of sorting out the more recent news items from the less recent news items.  We simply determine what 24 hours ago was, and then check each item to see if its timestamp is within that timeframe.

This will ONLY work for feeds where all items have timestamps.  This is NOT 100% reliable because some feeds simply don't have timestamps.</summary>
    </entry>
    <entry>
        <title>Setting up a cron job for SimplePie and SimplePie Plugin for Wordpress</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/setting_up_a_cron_job_with_simplepie"/>
        <published>2009-11-25T21:09:18+00:00</published>
        <updated>2009-11-25T21:09:18+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/setting_up_a_cron_job_with_simplepie</id>
        <summary>This procedure to set up a cron job to update the SimplePie cache in the background once an hour is similar for both SimplePie and SimplePie Plugin for Wordpress so I've combined them in one tutorial.

Compatibility

	*  Supported in SimplePie 1.0 or newer.
	*  Requires a Linux based host that allows cron jobs.</summary>
    </entry>
    <entry>
        <title>Shorten titles and descriptions</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/shorten_titles_and_descriptions"/>
        <published>2008-02-26T16:22:38+00:00</published>
        <updated>2008-02-26T16:22:38+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/shorten_titles_and_descriptions</id>
        <summary>There have been approximately 100 Jillion-Kabillion-Bazillion support questions asked about shortening titles and descriptions.

	*  Some people want to break at a certain number of characters.
	*  Some people want to break at a certain number of characters, but don't want to break words.
	*  Some people want to break after a certain number of words.
	*  Some people want to break after a certain number of sentences.
	*  Some people want to do all of these things and maintain HTML and entities.
	…</summary>
    </entry>
    <entry>
        <title>Sort multiple feeds by time and date</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date"/>
        <published>2012-07-09T01:54:52+00:00</published>
        <updated>2012-07-09T01:54:52+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date</id>
        <summary>In SimplePie 1.0, we simplified the process of merging together multiple feeds, sorting them by date, and displaying them.  This method allows you to do all of the normal SimplePie stuff without requiring you to do any array hacking or anything.

There are, however, two things to keep in mind about merging multiple feeds:</summary>
    </entry>
    <entry>
        <title>Sorting by custom criteria instead of date</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/sorting_by_custom_criteria_instead_of_date"/>
        <published>2013-05-20T07:18:52+00:00</published>
        <updated>2013-05-20T07:18:52+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/sorting_by_custom_criteria_instead_of_date</id>
        <summary>Sometimes you may want to sort items by custom criteria other than the time/date.  In the following example, we're going to sort the Digg feed by the number of diggs instead of by date.

:!: This tutorial assumes that you're already familiar with using SimplePie, including looping through items. It also assumes that you know how to use SimplePie Add-ons (specifically the Digg RSS Add-on).</summary>
    </entry>
    <entry>
        <title>Tips, Tricks, Tutorials, and Screencasts</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/start"/>
        <published>2013-02-11T12:45:53+00:00</published>
        <updated>2013-02-11T12:45:53+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/start</id>
        <summary>There are all sorts of cool things you can do with SimplePie and feeds.  These are some of the most popular code snippets and samples we've come across.  Feel free to add your own, but if there's a similar one to what you're wanting to post, please see if you can merge your notes into the one that already exists.</summary>
    </entry>
    <entry>
        <title>Translate timestamps into another language</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/translate_timestamps_into_another_language"/>
        <published>2007-06-19T01:52:31+00:00</published>
        <updated>2007-06-19T01:52:31+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/translate_timestamps_into_another_language</id>
        <summary>By default, PHP displays timestamps in English.  Since SimplePie's get_date() method relies on PHP's date() function, get_date() is English-only.  However, in SimplePie 1.0 we introduced get_local_date() which leverages PHP's strftime() function which is designed to translate timestamps into other languages.</summary>
    </entry>
    <entry>
        <title>Use Relative Dates</title>
        <link rel="alternate" type="text/html" href="http://simplepie.org/wiki/tutorial/use_relative_dates"/>
        <published>2007-09-10T18:32:58+00:00</published>
        <updated>2007-09-10T18:32:58+00:00</updated>
        <id>http://simplepie.org/wiki/tutorial/use_relative_dates</id>
        <summary>“Relative dates” is a method where instead of showing the exact date of a post, you can say it was posted “4 days ago.”  Tomorrow, this message would say “5 days ago.”

The information and code for this tutorial was taken from a Maniacal Rage posting entitled ”Relative Dates Using PHP.”  Although the original article was geared for Movable Type, we're going to apply it to feed items returned from SimplePie.</summary>
    </entry>
</feed>
