Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...