Jump to content
Sign in to follow this  
potatocake

How to create the rss.xml file

Recommended Posts

Hi,

 

I have placed a create_rss.php file with the following code:

 

<?php
require('includes/application_top.php');

  //$filename = DIR_FS_DOCUMENT_ROOT . FILENAME_RSS;
//if (is_writable($filename)) {

 // open a file pointer to an RSS file
 $fp = fopen (DIR_FS_DOCUMENT_ROOT . FILENAME_RSS, "w");

 // Now write the header information
 fwrite ($fp, "<?xml version='1.0' ?><rss version='2.0'><channel>”);

 fwrite ($fp, “<title>Your Title</title>");

 fwrite ($fp, "<link>" . HTTP_SERVER . "</link>");

 fwrite ($fp, "<description>Your description</description>");

 fwrite ($fp, "<language>en-us</language>");

 fwrite ($fp, "<docs>" . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_RSS . "</docs>");

  $news_query_raw = tep_db_query("select * from " . TABLE_NEWS . " order by id desc limit 10");
   while ($content_rec = tep_db_fetch_array($news_query_raw)) {
	fwrite ($fp, "<item>");

	$headline = $content_rec['name'];
	$date = 'Date: ' . tep_date_short($content_rec['date_created']);
	$content_1 = substr($content_rec['content'], 0, 250);
	$content = strip_tags($content_1);
	if (strlen($content_rec['content']) > 250) {
		$content = $content . "....";
	}
	fwrite ($fp, "<title>$headline</title>");
	fwrite ($fp, "<pubDate>$date</pubDate>");
	fwrite ($fp, "<description>$content</description>");
	$item_link = HTTP_SERVER . DIR_WS_CATALOG . FILENAME_NEWS . "?article=" . $content_rec['id'];
	fwrite ($fp, "<link>$item_link</link>");

	fwrite ($fp, "</item>");
}

   fwrite ($fp, "</channel></rss>");
fclose ($fp);

  tep_redirect(tep_href_link(FILENAME_NEWS, 'update=true'));
// } else {
  // tep_redirect(tep_href_link(FILENAME_NEWS, 'update=false'));
// }

?>

 

in the location of catalog/admin

 

I tried running this file and setting its chmod permissions to 777 but im getting these errors

Warning: fopen(/public_html/rss.php) [function.fopen]: failed to open stream: Permission denied in /public_html/admin/create_rss.php on line 8

Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/admin/create_rss.php on line 13

Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/admin/create_rss.php on line 15

Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/admin/create_rss.php on line 17

Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/admin/create_rss.php on line 19

Warning: fwrite(): supplied argument is not a valid stream resource in /public_html/admin/create_rss.php on line 21

 

Could i get some help as to how this is done properly. I havent been able to find a post with the full instructions on how to do this.

 

Thanks heaps

Share this post


Link to post
Share on other sites

I figured out that it was the permissions and have fixed the errors coming in but still no rss.xml file could someone please shed some light on the situation.

 

thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×