Rockin’ RSS with PHP on your HTML - Tease the reader (
Page 6 of 6 )
And essentially that’s it. Notice how I did NOT put the entire content into the RSS feed. You can put the entire content into the file if you want. Personally, I don’t recommend doing this. Instead, put just enough to tease the reader so that they want to visit your site.
Now, you will note that I do move the data around just a bit to not only shorten the length of what I’m sending out on the feed, but also to add the ellipses to let readers know there is more.
And again, how you decide to database your content will affect exactly how you pull that content out.
Anyway, at this point, all we need to do is close off the file.
fwrite ($fd, "</channel></rss>"); fclose ($fd);
?>
It is a simple enough process. You can now have that ran by a cron job, or simply run the php file from a browser once a day.
Again, if you are running some sort of a content management system (and I’ll talk about how to easily build your own in future articles), creating the RSS file is obviously a simple matter of writing the static “header” information for your site/feed, pulling the content out of the database, writing each item of new content between “<item>” tags, and then closing the file off with the ending tags.
You may want to add in some other information into this feed, and again, we’ll also talk about what other information there is to add, and why you may want to put that into the feed. We’ll also talk about, if you are adding content via RSS feeds to your site, how to make THAT content from that OTHER feed a part of your own RSS feed. This will ensure that you’ve got a constantly updating RSS feed so that people will want to keep coming back to your site, driving up traffic, unique visitors per day, and page views per visitor.
| | Discuss Rockin’ RSS with PHP on your HTML | | | | | | | Simple but informative article on using RSS with PHP. | | | | | | Good article, but why write to a static file instead of creating the feed on_the_fly... | | | | | | I've used this article to help me set up a RSS feed for the site I'm working on. On... | | | | | | Hello,
it works fine, the xml file is created as it should but when I visit my... | | | | | | You can use the script to create the file on the fly really with only a handfull of... | | | | | | There's a very simple reason why you are skipping a story.
The problem is in this... | | | | | | Have you tried simply typing the full URL into your address bar of your XML... | | | | | | I appreciate the comment. The idea behind the article was to keep it simple ...... | | | | | | Think about it. How often do you add content to your site versus how often someone... | | | | | | Just wanted to say that this article was very usefull. Simple and easy to use,... | | | | | | First of all, in all seriousness, the RSS spec is pretty easy. The one I use a lot... | | | | | | Some typos in the article:
On this... | | | | | | Thanks for noticing that. | | | | | | I'm trying to setup this RSS for the first time using the script and MAGPIE RSS... | | | | | | The table you need to create is called "content" and needs to have 5... | | | | | | I added the table, you said 5 fields but only wrote down 4. Are there only... | | | | | | First, you don't need magpie to run the script I've given you. If you remember from... | | | | | | I loaded the database with info, and moved the script to the main directory and I... | | | | | | I have no idea where the fetch_assoc came from.
The line should be fetch_row. ... | | | | | | Could you just send me a clean script, sorry for making this so difficult. I don't... | | | | | | Just let me know your email address and I'll send it to you. | | | | | | Hey guys. I can follow most of this document and am new to php. still learning... | | | | | | In the line of code where you are opening the file you give a full URL. That's your... | | | | | | I been trying to run the script on my website and is not working.
Here is what I... | | | | | | This script isn't for making feeds appear on your website. This script is for... | | | | | | Hi there, thanks for your time,
I put the script on a page called create_rss.php,... | | | | | | when i run the create_rss.php file it give me the following error:
I cannot connect... | | | | | | when i run the create_rss.php file it give me the following error:
I cannot connect... | | | | | | Sorry if this seems a little "testy" ... but this script is for CREATING the rss... | | | | | | Hi again,
Thanks for your help, now the script is half working this is the final... | | | | | | Hi Mr Wall,
Please don't post this message.
I need to get in contact with you... | | | | | | More likely than not your problem is that you don't have the proper user name and... | | | | | | For starters, your fclose() statement has a typo.
it should read... | | | | | | Danny,
I've been trying to run your script and keep getting permission errors. ... | | | | | | I'm sure there are a few problems here - i am a beginner, but on the way to getting... | | | | | | I put it all online so now here is what's shiwing up in my error... | | | | | | My script was stripped so here it is below without the html:
<?php
// open a... | | | | | | I need help. I guess I responded to another message someone else wrote but here is... | | | | | | Look at your SQL statement. Do you have that table in your database? Are there any... | | | | | | I troubleshot and troubleshot and finally after working with someone, they found out... | | | | | | Get the Resolution to the wackjob's problem at the top of the comments (currently... | | | | | | this uses mysql - not MICROSOFT Access | | | | | | The answer is posted in this forum - i believe it was that 'index' (no quotes)... | | | | | | what's with the html tags?
anyways, this was solved in this forum on 8-17-05 - its... | | | | | | You were the only one that responded to this - I have since filled in responses to... | | | | | | Hi, thanks for all the articles on here, they're really showing me that I know... | | | | | | Actually, if you want to get user specific, on the fly generation of your xml is the... | | | | | | Tried to change the permission of the folder you are writing the xml into? Perhaps... | | | | | | Thanks guys, all of this has been a big help, but something is not working for me. ... | | | | | | If you remember, I said that query was the one to pull data out of my content... | | | | | | Danny,
Thank you for the quick reply. I replaced the sample database and login... | | | | | | You'll still need an id field set as the primary key and set to autoincrement. Once... | | | | | | what do i do with files once i create them?
Do put the PHP code in with the .xml... | | | | | | I don't WANT to get into all the coding stuff. Nor do I want to syndicate my site. ... | | | | | | Day one of my quest for a SEO-friendly RSS display on my .html page was from 7 am to... | | | | | | >>> Post your comment now! | | | | | |
|
 |
|