So, you built a website with an amazing strength of potential for millions of internet aficionados to venture, read information, blog, whatever –and maybe make you a few pesos in the big scheme of things. There is a simple, yet powerful tool to gain traffic through: RSS.
RSS means Really Simple Syndication. To syndicate just means gather all the information in once place, where people can subscribe via their web browser, to an article list. But, the words “really simple” on the programming side, are not so simple –as you might have guessed. Creating an RSS Feed, should be quite easy. And after racking my brain for days over the programming connection between my existing PHP website and testing out several Feed Generators { like Mag Pie or Simply Smarty } had a moment where my iMac nearly plunged out the window.
Luckily, I remained calm and went back to my old school PHP programming know-how for the answer to Customizing An RSS Feed without bloated parsers. The customization of this type of Feed creates a Username based RSS Channel in PHP, that returns valid. For each user generated page, you can place the link to that specific group of Articles on the website. The system automatically creates the files needed with each registration. This means less work for you, more flexibility, certainly no manual entry – and if all goes well, increased subscribers.
Creating the entire Custom RSS Feed will take you minutes, literally. From here you can allow Members to jack into Feedburner, Pheedo or any other Syndication they prefer, which can also be used for Internal Tax and Folks -onomy. You will need three {3} items in all:
A Make File function at Member Registration The PHP-XML Hybrid File { template } The Output Script/Feed Link
1. A Make File function at Member Registration
On the Registration Confirmation page call a MAKE FILE function. This tells the server to create a file titled Username.rss.php. It is vital you make this file, else the RSS Output will not be created. The function gets the POST Username and tells the server to MAKE FILE called Username.rss.php.
$USERNAME=$_POST['USERNAME']; $FILE=$USERNAME.'.rss.php'; if(!$handle=fopen($FILE, 'a')) { echo "Crickets, cannot open file ($FILE)"; exit } $ginger=file_get_contents("rss.php");
2. The PHP-XML Hybrid File { template }
Now, here is the tricky part: you will need to GET the base RSS-PHP hybrid Template. Why? This saves a lot of time and headache. The function gets all the Template information and appends it to the new file called Username.rss.php. This will include the RSS Elements for each Member who joins. Write the header to the new RSS file and move it to the proper directory. { You may choose whatever folder you like, just so long as you remember where you created it so you may link it later on }. The above code now automatically creates the RSS-PHP file in that directory. In order for that file to be created, you need the base code or Hybrid Template, and obviously a connection to the database.
3. The Output Script/Feed Link
One of the unique features of RSS, it is written in XML. Essentially, you can customize the items like Title, Main URL, Main Photo and Child Elements as well. Some browsers will enable photos for each feed listing, some do not. Feedburner and Pheedo definitely do, by creating an XHTML (XML+HTM) page for the feed. This is great for putting in Ads.
The issue with RSS/XML and PHP is simply the language. Communication between is like speaking Russian to a Dolphin, neither understand a word the other is saying. However, there is a way to unite the languages and everyone go home happy. This is called parsing. One language meets another and information is translated. In fact, the parser IS the translator. To make this work, we tell the server this PHP File, should be read as an XML file. This is found in the Content Type. Most web pages tell you in the header what type of content is designed or allowed for the page. If you are using XHTML Transitional or even Strict, you can display pretty much any code. With PHP/XML you need to specifically assign which Content Type. In this case, XML/RSS. Let’s create the Main RSS Template file first and customize it.
header(Content-Type: application/rss+xml; charset=ISO-8859-1); require_once('mydataconnect.php'); $USERNAME= basename($_SERVER['SCRIPT_FILENAME']); $USERNAME= str_replace('_',' ',$USERNAME); $USERNAME= str_replace('.rss.php','',$USERNAME); $USERNAME= strtolower($USERNAME); $USERNAME= ucfirst($USERNAME); $feed = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $feed .= '<rss version="2.0">'; $feed .= '<channel>'; $feed .= '<title>Your RSS</title>'; $feed .= '<link>http://www.yourwebsite.com</link>'; $feed .= '<description>Describe...