Jump to content
Ralph2

RSS Feed contribution support thread

Recommended Posts

I have installed the useful ADD-ON but here have a problems :

 

 

Top Category feeds not displaying when Top category has sub-categories (sub-categories show fine).

 

Example:

Category 1 ===> displays fine

Category 2 ===> DOESN'T DISPLAY

L Sub-Category 1 ===> displays fine

L Sub-Category 2 ===> displays fine

Category 3 ===> displays fine

 

 

 

anybody can help?

Share this post


Link to post
Share on other sites

Hello,

please how I can modify category language? because all like name, description is from actual language whitin category name. Please help me.

here is my modified code:

<?php
/*
 $Id: rss.php,v 2.0 2007/05/12 19:30:06 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

/*
* Include the application_top.php script
*/
require('includes/application_top.php');

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_RSS);

$navigation->remove_current_page();

// If the language is not specified
 $lang_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$languages_id . "'");

// Recover the code (fr, en, etc) and the id (1, 2, etc) of the current language
if (tep_db_num_rows($lang_query)) {
 $lang_a = tep_db_fetch_array($lang_query);
   $lang_code = $lang_a['code'];
}

define(RSS_STRIP_HTML_TAGS,false);
// If the default of your catalog is not what you want in your RSS feed, then
// please change this three constants:
// Enter an appropriate title for your website
define(RSS_TITLE, STORE_NAME);
// Enter your main shopping cart link
define(WEBLINK, HTTP_SERVER);
// Enter a description of your shopping cart
define(DESCRIPTION, TITLE);
/////////////////////////////////////////////////////////////
//That's it.  No More Editing (Unless you renamed DB tables or need to switch
//to SEO links (Apache Rewrite URL)
/////////////////////////////////////////////////////////////

$store_name = STORE_NAME;
$rss_title = RSS_TITLE;
$weblink = WEBLINK;
$description = DESCRIPTION;
$email_address = STORE_OWNER_EMAIL_ADDRESS;

$subtitle = '';

function replace_problem_characters($text) {
   $formattags = array("&"); 	
   $replacevals = array("&");
   $text = str_replace($formattags, $replacevals, $text);
   //$in[] = '@&(amp|#038);@i'; $out[] = '&';
   $in[] = '@&(#036);@i'; $out[] = '$';
   $in[] = '@&(quot);@i'; $out[] = '"';
   $in[] = '@&(#039);@i'; $out[] = '\'';
   $in[] = '@&(nbsp|#160);@i'; $out[] = ' ';
   $in[] = '@&(hellip|#8230);@i'; $out[] = '...';
   $in[] = '@&(copy|#169);@i'; $out[] = '(c)';
   $in[] = '@&(trade|#129);@i'; $out[] = '(tm)';
   $in[] = '@&(lt|#60);@i'; $out[] = '<';
   $in[] = '@&(gt|#62);@i'; $out[] = '>';
   $in[] = '@&(laquo);@i'; $out[] = '«';
   $in[] = '@&(raquo);@i'; $out[] = '»';
   $in[] = '@&(deg);@i'; $out[] = '°';
   $in[] = '@&(mdash);@i'; $out[] = '—';
   $in[] = '@&(reg);@i'; $out[] = '®';
$in[] = '@&(–);@i'; $out[] = '-';
   $text = preg_replace($in, $out, $text);
return $text;
}

function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.

$search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
				 "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
				 //"'([rn])[s]+'",                // Strip out white space
				 "'&(quot|#34);'i",                // Replace HTML entities
				 "'&(amp|#38);'i",
				 "'&(lt|#60);'i",
				 "'&(gt|#62);'i",
				 "'&(nbsp|#160);'i",
				 "'&(iexcl|#161);'i",
				 "'&(cent|#162);'i",
				 "'&(pound|#163);'i",
				 "'&(copy|#169);'i",
				 "'(d+);'e");                    // evaluate as php

$replace = array ("",
				 "",
				 //"\1",
				 "\"",
				 "&",
				 "<",
				 ">",
				 " ",
				 chr(161),
				 chr(162),
				 chr(163),
				 chr(169),
				 "chr(\1)");

return preg_replace($search, $replace, $str);
}


 if(!function_exists('eval_rss_urls')) {
   function eval_rss_urls($string) {
		// rewrite all local urls to absolute urls
	return preg_replace_callback("/(href|src|action)=[\"']{0,1}(\.{0,2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is","rewrite_rss_local_urls",$string);
	//"/(href|src|action)=[\"']{0,1}(\.{2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is"
}
 } 

 	function rewrite_rss_local_urls($string) {

$repl_text = $string[0];
$repl_by = HTTP_SERVER.'\\';
$repl_len = 0;

$index_pos = strpos  ( $repl_text , '..');
if ($index_pos > -1) {
	$repl_len = 2;	
} else {
 	$index_pos = strpos  ( $repl_text , '\"\\');	
	if ($index_pos > -1) {
		$repl_len = 0;	
		$index_pos+=1;
	}
}
if ($index_pos > -1) {
	substr_replace($repl_text, $repl_by, $index_pos,2 );	
}
	ob_start();
		echo $repl_text;
		$return = ob_get_contents();
	   ob_end_clean();
	return $return;
}

// to strip html or not to strip html tags
if (isset($HTTP_GET_VARS['html'])) {
if ($HTTP_GET_VARS['html']=='false') {
	$strip_html_tags = true;	
} else {
	$strip_html_tags = false;	
}
} else {
$strip_html_tags = RSS_STRIP_HTML_TAGS;
}

// show the products of a specified manufacturer

   if (isset($HTTP_GET_VARS['manufacturers_id'])) {

     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

// We are asked to show only a specific category

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
              ON p2c.categories_id = cd.categories_id where p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' 
		   GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
              ON p2c.categories_id = cd.categories_id  where p.products_status = '1' and p.products_to_rss='1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id']  . "' 
		   GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";


     }

  $subtitle = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['manufacturers_name'];
 	  $rss_title = BOX_INFORMATION_RSS_MANUFACTURER;
   } else if (tep_not_null($current_category_id)) {

// show the products in a given categorie

     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
              ON p2c.categories_id = cd.categories_id where p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id  . "' 
		   GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
              ON p2c.categories_id = cd.categories_id where p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' 
		   and p2c.categories_id = '" . (int)$current_category_id  . "' 
		   GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";
     }

   	$subtitle= tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['categories_name'];
  	  $rss_title = BOX_INFORMATION_RSS_CATEGORY;

   } else {

	// show realy al products
        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
              ON p2c.categories_id = cd.categories_id where p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "'  
		   GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

	$rss_title = BOX_INFORMATION_RSS;
}
//	echo $listing_sql;
// Execute SQL query and get result
$query = tep_db_query($listing_sql);

/*
 * If there are returned rows...
 * Basic sanity check 
 */
if ( tep_db_num_rows($query) > 0 ){

if ($subtitle != '') $rss_title .= ' - '.$subtitle;

// Encoding to UTF-8
//$store_name =  utf8_encode (replace_problem_characters($store_name));
//$rss_title =  utf8_encode (replace_problem_characters($rss_title));
//$weblink =  utf8_encode ($weblink);
//$description =  utf8_encode (replace_problem_characters($description));
//$email_address =  utf8_encode ($email_address);

// SQL header(Last-Modified)
$last_modified = '';
$sql = "SELECT MAX(products_date_added) as mPla, MAX(products_last_modified) as mPlm FROM products WHERE products_to_rss = '1' ORDER BY products_id DESC LIMIT 1";
 $sql_result = tep_db_query($sql);
   $row = tep_db_fetch_array($sql_result);

if ($row['mPlm'] != '') { $last_modified = $row['mPlm']; }
else { $last_modified = $row['mpla']; }

 if(!function_exists('getallheaders')){
	function getallheaders(){
		settype($headers,'array');
		foreach($_SERVER as $h => $v){
			if(ereg('HTTP_(.+)',$h,$hp)){
				$headers[$hp[1]] = $v;
			}
		}
		return $headers;
	}
 }

$headers = getallheaders(); 

 $refresh = 1; // refresca por defecto 
 $etag = md5($last_modified);

 if(isset($headers["If-Modified-Since"])) { // Verificamos fecha enviada por el lector RSS
 	$since = strtotime($headers["If-Modified-Since"]); 
if($since >= strtotime($last_modified)) { $refresh = 0; }
 } 

 if(isset($headers["If-None-Match"])) { // Verificamos el ETag
 	if(strcmp($headers["If-None-Match"], $etag) == 0) {
  $refresh = 0;
} else {
  $refresh = 1;
}
 }

 if($refresh == 0) {
   header("HTTP/1.1 304 Not changed");
   // La primera línea de los headers debe ser el status
   // sino el Netcrap se lía y da "No Data"
   ob_end_clean(); // Descartamos los contenidos del búfer de salida en cola y lo deshabilitamos
 }


// Begin sending of the data
header('Content-Type: application/rss+xml; charset=windows-1250');
//header("Last-Modified: " . tep_date_raw($last_modified));
header('Last-Modified: ' .gmdate("D, d M Y G:i:s", strtotime($last_modified)). ' GMT');
//header('Last-Modified: ' .gmdate("D, d M Y G:i:s T",strtotime($last_modified)) . ' GMT');
header("ETag: " . md5($etag));

echo "<?xml version='1.0' encoding='windows-1250' ?>" . "\n";
?>
<CATALOG>
<LOGO><?php echo $weblink . DIR_WS_CATALOG.'images/store_logo.png';?></LOGO>

<?php
// Format results by row
while( $row = tep_db_fetch_array($query) ){
 $id = $row['products_id'];

 // RSS Links for Ultimate SEO (Gareth Houston 10 May 2005)
 $link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id, 'NONSSL', false);

 $model = $row['products_model'];
 $image = $row['products_image'];
 $added = date(r,strtotime($row['products_date_added']));

 // Setting and cleaning the data
 $name = $row['products_name'];
 $desc = eval_rss_urls($row['products_description']);

 // Encoding to UTF-8  
 if ($strip_html_tags ==true) {
 	$name = strip_html_tags($name);
 	$desc = strip_html_tags($desc);
 }

//  $name = utf8_encode(replace_problem_characters($name));
//  $desc = utf8_encode(replace_problem_characters($desc));
//  $link = utf8_encode($link);

 $manufacturer = $row['manufacturers_name'];
 //$manufacturer = utf8_encode ($manufacturer);
//  $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));


   if (tep_not_null($row['specials_new_products_price'])) {
$price = tep_add_tax($row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));
   } else {
      $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));
   }

 if( $discount = tep_get_products_special_price($id) ) {
   $offer = tep_add_tax($discount, tep_get_tax_rate($row['products_tax_class_id']));
 } else {
   $offer = '';
 }
//add price limit decimals to 2  
$price = sprintf("%01.2f", $price);

 $cat_name = $row['categories_name'];

 // Encoding to UTF-8
// $cat_name = utf8_encode (replace_problem_characters(strip_html_tags($cat_name)));

 // Setting the URLs to the images and buttons
 $relative_image_url = tep_image(DIR_WS_IMAGES . $image, $name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'style="float: left; margin: 0px 8px 8px 0px;"');
 $relative_image_url = str_replace('">', '', $relative_image_url);
 $relative_image_url = str_replace('<img src="', '', $relative_image_url);
 $image_url = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $image;

 $relative_buy_url = tep_image_button('button_shopping_cart.gif', IMAGE_BUTTON_IN_CART, 'style="margin: 0px;"');
 $relative_buy_url = str_replace('">', '', $relative_buy_url);
 $relative_buy_url = str_replace('<img src="', '', $relative_buy_url);
 $buy_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_buy_url;

 $relative_button_url = tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO, 'style="margin: 0px;"');
 $relative_button_url = str_replace('">', '', $relative_button_url);
 $relative_button_url = str_replace('<img src="', '', $relative_button_url);
 $button_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_button_url;


 // http://www.w3.org/TR/REC-xml/#dt-chardata
 // The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form
 $name = str_replace('&','&',$name);
 $desc = str_replace('&','&',$desc);
 $link = str_replace('&','&',$link);
 //$cat_name = str_replace('&','&',$cat_name);

 $name = str_replace('<','<',$name);
 $desc = str_replace('<','<',$desc);
 $link = str_replace('<','<',$link);
 $cat_name = str_replace('<','<',$cat_name);

 $name = str_replace('>','>',$name);
 $desc = str_replace('>','>',$desc);
 $link = str_replace('>','>',$link);
 $cat_name = str_replace('>','>',$cat_name);


 $buy_link = tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $id);
 // Encoding to UTF-8
//  $buy_link = utf8_encode ($buy_link);
 $buy_link = str_replace('&','&',$buy_link);
 $buy_link = str_replace('<','<',$buy_link);
 $buy_link = str_replace('>','>',$buy_link);

 // Writing the output
 echo '<ITEM>' . "\n";
 echo '  <ID>' . $id . '</ID>' . "\n";
 echo '  <TITLE>' . $name . '</TITLE>' . "\n";
 echo '  <DESCRIPTION>' . $name . '</DESCRIPTION>' . "\n";

 echo '  <PRICE>' . $price . '</PRICE>' . "\n";
 echo '  <CATEGORY>' . $cat_name . '</CATEGORY>' . "\n";

 echo '  <URL>' . $link . '</URL>' . "\n";
 echo '  <IMAGE>' . $image_url . '</IMAGE>' . "\n";

 echo '  <MANUFACTURER>' . $manufacturer . '</MANUFACTURER>' . "\n";
 echo '  <DUES>' . 'ZADARMO V CELEJ SR' . '</DUES>' . "\n";


 echo '</ITEM>' . "\n";
}
}

echo '</CATALOG>' . "\n";


/*
 * Include the application_bottom.php script 
 */
include_once('includes/application_bottom.php');
?>

Share this post


Link to post
Share on other sites

Hi I am getting this error when trying to run the sql

 

INSERT INTO configuration( configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function )

VALUES (

 

'24', 'RSS Articles', 'MAX_RSS_ARTICLES', '20', 'Number of articles displayed by the RSS feed', '3', '25', '2007-03-14 22:15:35', '2007-03-14 22:15:35', NULL , NULL

);

 

 

 

MySQL said:

 

#1062 - Duplicate entry '24' for key 1

 

 

I have changed so many a times the configuration group id value, always to non occupied ones but still I can't manage to overcome this... :angry:

 

Any Help

Share this post


Link to post
Share on other sites

Try this:

INSERT INTO configuration( configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function )
VALUES (

'', 'RSS Articles', 'MAX_RSS_ARTICLES', '20', 'Number of articles displayed by the RSS feed', '3', '25', '2007-03-14 22:15:35', '2007-03-14 22:15:35', NULL , NULL
);

Share this post


Link to post
Share on other sites

Hi

is there a way that when a product is sold and it is not available anymore the entry in the RSS feed is also removed for the same product.

How can I modify the contrib to do that?

Thanks


OSC beginner

Share this post


Link to post
Share on other sites

I don't think that that is possible as RSS is a news feed rather than a history feed, but what you could do is have a news page feeding into the RSS then when you update your news page - eg. "We are sorry to say that our popular product is now sold out and is no longer available etc." - It would also help if you had a store with a low turnover of new articles, very much like publishing a news letter every couple of days ;)

Share this post


Link to post
Share on other sites

How can I limit my rss output to below 512k?

 

Feedburner does not accept feeds larger the 512k

 

Cheers


-Peder Beckman-

Kool Kat Jazz Records

Share this post


Link to post
Share on other sites

Any way to have a image of the product showing up instead of the rss_logo?

 

Cheers


-Peder Beckman-

Kool Kat Jazz Records

Share this post


Link to post
Share on other sites

This is what I am getting after install, I have the newest rss.php as well.

 

Sorry

 

This feed does not validate.

 

line 211, column 0: XML parsing error: <unknown>:211:0: junk after document element [help]

<script type="text/javascript">

 

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

line 13, column 21: Image title doesn't match channel title [help]

 

<title>UsbDirect.ca</title>

^

line 169, column 9: title should not be blank [help]

<title></title>

^

line 209, column 0: Missing atom:link with rel="self" [help]

</channel>

 

Any help would be great, would love to get this going :) Thanks!

Share this post


Link to post
Share on other sites

Can anyone explain why non-breaking space & # 1 6 0 ; is displayed in my feed? is it the FCK editor?

 


<p>&#38;#160;</p>
<p>Christys egen&#38;#160;beskrivelse af varen:</p>

<p>Available in palette of&#38;#160;rich colours, by using 100% organic cotton and low impact dyes, we have created a range of natural products that are not only soft and luxurious to touch, but also environmentally friendly.</p>


I'm the owner of a danish gift shop, where you will find gifts, ideas & presents for her & him.

Share this post


Link to post
Share on other sites

Hi all

 

Forgive me if this has been discussed. I have the contribution working but I want to change the items in the feed. I have thousands of items but I can only get the newest ones to show in the feed. Most of them will not be updated so they don't show up. Is there a way to change it so different ones will show up or just be able to set up different feeds without having to go thru each category unchecking items.

Share this post


Link to post
Share on other sites

I don't know much about RSS, but I have installed this contribution on my website: Tasker

But when I try to add the RSS.php I just get an error message saying the link is not a valid RSS.

 

Also when I use the validator I get errors:

http://www.feedvalidator.org/check?url=http://www.fashionsense.dk/rss.php

 

Can anyone help me with this?

Share this post


Link to post
Share on other sites

Hi,

 

If i want to have an XML feed of products coming from one of our suppliers which will be automatically shown on our site with their prices etc. and buy now buttons linking to their shopping cart, is this the mod im looking for? Or does this mod just output an XML feed of my own stores products for others to use?

 

We have a catalog of products already on our site but we'd like to also offer one of our suppliers product catalog on our site through an XML feed which will hopefully automatically add all of their products to our site.

 

Thanks.

Share this post


Link to post
Share on other sites

The only major problem I'm getting at the moment is that rss.php is not converting code from the database so á stays as á and not á so all my Cyrillic script turns out as &****;&****; and so on

 

 

Does anyone have an idea on a cure?

 

 

This issue does not seem to be sorted yet?

I cannot understand how a mod can exist for so long and have so many changes and yet a major problem with the output is being left unadressed. The feed is useless if its full of &nbps;

 

Is anyone working on it or have a solution?

Share this post


Link to post
Share on other sites

you excuse the grammar, use an on-line translator.

I have modified the code this way:

<?php
/*
 $Id: rss.php,v 2.0 2007/05/12 19:30:06 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

/*
* Include the application_top.php script
*/
require('includes/application_top.php');

$navigation->remove_current_page();

// If the language is not specified
 $lang_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$languages_id . "'");

// Recover the code (fr, en, etc) and the id (1, 2, etc) of the current language
if (tep_db_num_rows($lang_query)) {
 $lang_a = tep_db_fetch_array($lang_query);
   $lang_code = $lang_a['code'];
}

define('RSS_STRIP_HTML_TAGS', false);
// If the default of your catalog is not what you want in your RSS feed, then
// please change this three constants:
// Enter an appropriate title for your website
define('RSS_TITLE', STORE_NAME);
// Enter your main shopping cart link
define('WEBLINK', HTTP_SERVER);
// Enter a description of your shopping cart
define('DESCRIPTION', TITLE);
/////////////////////////////////////////////////////////////
//That's it.  No More Editing (Unless you renamed DB tables or need to switch
//to SEO links (Apache Rewrite URL)
/////////////////////////////////////////////////////////////

$store_name = STORE_NAME;
$rss_title = RSS_TITLE;
$weblink = WEBLINK;
$description = DESCRIPTION;
$email_address = STORE_OWNER_EMAIL_ADDRESS;

$subtitle = '';

function replace_problem_characters($text) {
   $formattags = array("&");
   $replacevals = array("&");
   $text = str_replace($formattags, $replacevals, $text);
  $in[] = '@&(amp|#038);@i'; $out[] = '&';
   $in[] = '@&(#036);@i'; $out[] = '$';
   $in[] = '@&(quot);@i'; $out[] = '"';
   $in[] = '@&(#039);@i'; $out[] = '\'';
   $in[] = '@&(nbsp|#160);@i'; $out[] = ' ';
   $in[] = '@&(hellip|#8230);@i'; $out[] = '...';
   $in[] = '@&(copy|#169);@i'; $out[] = '(c)';
   $in[] = '@&(trade|#129);@i'; $out[] = '(tm)';
   $in[] = '@&(lt|#60);@i'; $out[] = '<';
   $in[] = '@&(gt|#62);@i'; $out[] = '>';
   $in[] = '@&(laquo);@i'; $out[] = '«';
   $in[] = '@&(raquo);@i'; $out[] = '»';
   $in[] = '@&(deg);@i'; $out[] = '°';
   $in[] = '@&(mdash);@i'; $out[] = '—';
   $in[] = '@&(reg);@i'; $out[] = '®';
   $in[] = '@&(–);@i'; $out[] = '-';
   $text = preg_replace($in, $out, $text);
   return $text;
}

function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.

   $search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
                    "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
                    //"'([rn])[s]+'",                // Strip out white space
                    "'&(quot|#34);'i",                // Replace HTML entities
                    // "'&(amp|#38);'i",
                    "'&(lt|#60);'i",
                    "'&(gt|#62);'i",
                    "'&(nbsp|#160);'i",
                    "'&(iexcl|#161);'i",
                    "'&(cent|#162);'i",
                    "'&(pound|#163);'i",
                    "'&(copy|#169);'i",
                    "'(d+);'e");                    // evaluate as php

   $replace = array ("",
                    "",
                    //"\1",
                    "\"",
                    "&",
                    "<",
                    ">",
                    " ",
                    chr(160),
                    chr(161),
                    chr(162),
                    chr(163),
                    chr(169),
                    "chr(\1)");

   return preg_replace($search, $replace, $str);
}


 if(!function_exists('eval_rss_urls')) {
   function eval_rss_urls($string) {
           // rewrite all local urls to absolute urls
       return preg_replace_callback("/(href|src|action)=[\"']{0,1}(\.{0,2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is","rewrite_rss_local_urls",$string);
       //"/(href|src|action)=[\"']{0,1}(\.{2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is"
   }
 } 

     function rewrite_rss_local_urls($string) {

   $repl_text = $string[0];
   $repl_by = HTTP_SERVER.'\\';
   $repl_len = 0;

   $index_pos = strpos  ( $repl_text , '..');
   if ($index_pos > -1) {
       $repl_len = 2;
   } else {
        $index_pos = strpos  ( $repl_text , '\"\\');
       if ($index_pos > -1) {
           $repl_len = 0;
           $index_pos+=1;
       }
   }
   if ($index_pos > -1) {
       substr_replace($repl_text, $repl_by, $index_pos,2 );
   }
       ob_start();
           echo $repl_text;
           $return = ob_get_contents();
          ob_end_clean();
       return $return;
   }

// to strip html or not to strip html tags
if (isset($_GET['html'])) {
   if ($_GET['html']=='false') {
       $strip_html_tags = true;
   } else {
       $strip_html_tags = false;
   }
} else {
   $strip_html_tags = RSS_STRIP_HTML_TAGS;
}

// show the products of a specified manufacturer

   if (isset($_GET['manufacturers_id'])) {

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {

// We are asked to show only a specific category

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id  left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id']  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";


     }

     $subtitle = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['manufacturers_name'];
       $rss_title = BOX_INFORMATION_RSS_MANUFACTURER;
   } else if (tep_not_null($current_category_id)) {

// show the products in a given categorie

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' 
              and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";
     }

       $subtitle= tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['categories_name'];
        $rss_title = BOX_INFORMATION_RSS_CATEGORY;

   } else {

       // show realy al products
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "'  
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

       $rss_title = BOX_INFORMATION_RSS;
   }
//    echo $listing_sql;
// Execute SQL query and get result
$query = tep_db_query($listing_sql);

   /*
    * If there are returned rows...
    * Basic sanity check 
    */
   if ( tep_db_num_rows($query) > 0 ){

if ($subtitle != '') $rss_title .= ' - '.$subtitle;

// Encoding to UTF-8
$store_name =  utf8_encode (replace_problem_characters($store_name));
$rss_title =  utf8_encode (replace_problem_characters($rss_title));
$weblink =  utf8_encode ($weblink);
$description =  utf8_encode ($description);
$email_address =  utf8_encode ($email_address);

   // SQL header(Last-Modified)
$last_modified = '';
$sql = "SELECT MAX(products_date_added) as mPla, MAX(products_last_modified) as mPlm FROM " . TABLE_PRODUCTS. " WHERE products_to_rss = '1' ORDER BY products_id DESC LIMIT 1";
 $sql_result = tep_db_query($sql);
   $row = tep_db_fetch_array($sql_result);

   if ($row['mPlm'] != '') { $last_modified = $row['mPlm']; }
   else { $last_modified = $row['mpla']; }

 if(!function_exists('getallheaders')){
       function getallheaders(){
           settype($headers,'array');
           foreach($_SERVER as $h => $v){
               if(preg_match('/HTTP_(.+)/',$h,$hp)){
                   $headers[$hp[1]] = $v;
               }
           }
           return $headers;
       }
 }

$headers = getallheaders(); 

 $refresh = 1; // refresca por defecto 
 $etag = md5($last_modified);

 if(isset($headers["If-Modified-Since"])) { // Verificamos fecha enviada por el lector RSS
     $since = strtotime($headers["If-Modified-Since"]); 
   if($since >= strtotime($last_modified)) { $refresh = 0; }
 } 

 if(isset($headers["If-None-Match"])) { // Verificamos el ETag
     if(strcmp($headers["If-None-Match"], $etag) == 0) {
     $refresh = 0;
   } else {
     $refresh = 1;
   }
 }

 if($refresh == 0) {
   header("HTTP/1.1 304 Not changed");
   // La primera línea de los headers debe ser el status
   // sino el Netcrap se lía y da "No Data"
   ob_end_clean(); // Descartamos los contenidos del búfer de salida en cola y lo deshabilitamos
 }


// Begin sending of the data
@header('Content-Type: application/rss+xml; charset=UTF-8');

//header("Last-Modified: " . tep_date_raw($last_modified));
@header('Last-Modified: ' .gmdate("D, d M Y G:i:s", strtotime($last_modified)). ' GMT');
//header('Last-Modified: ' .gmdate("D, d M Y G:i:s T",strtotime($last_modified)) . ' GMT');
@header("ETag: " . md5($etag));
echo '<!-- RSS for ' . $store_name . ', generated on ' . gmdate("D, d M Y G:i:s", strtotime($last_modified)) . ' GMT'. ' -->' . "\n";
$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0">
<channel>
<title><?php echo utf8_encode($rss_title); ?></title>
<link><?php echo $weblink;?></link>
<description><?php echo utf8_encode($description); ?></description>
<!--<atom:link href="<?php echo tep_href_link(FILENAME_RSS, $_SERVER['QUERY_STRING'] = str_replace('&','&',$_SERVER['QUERY_STRING']), 'NONSSL', false ); ?>" rel="self" type="application/rss+xml" /> Remove comments if you want this to remain -->
<webMaster><?php echo $email_address . ' (' .STORE_OWNER.')'; ?></webMaster>
<language><?php echo $lang_code; ?></language>
<lastBuildDate><?php echo gmdate("D, d M Y H:i:s", strtotime($last_modified)). ' GMT'; ?></lastBuildDate>
<image>
 <url><?php echo $weblink . DIR_WS_CATALOG . bts_select(images, 'logo_rss.png'); ?></url> 
 <title><?php // echo utf8_encode($rss_title); // 
             ?><?php echo utf8_encode($store_name); ?></title>
 <link><?php echo $weblink;?></link>
 <description><?php echo utf8_encode($description); ?></description>
 <width>100</width>
 <height>50</height>
</image>
<copyright>Copyright reserved</copyright> 
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php
// Format results by row
while( $row = tep_db_fetch_array($query) ){
 $id = $row['products_id'];

 // RSS Links for Ultimate SEO (Gareth Houston 10 May 2005)
 $link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id, 'NONSSL', false);

 $model = $row['products_model'];
 $image = $row['products_image'];
 $added = date(r,strtotime($row['products_date_added']));

 // Setting and cleaning the data
 $name = $row['products_name'];
 $desc = eval_rss_urls($row['products_description']);

 // Encoding to UTF-8  
 if ($strip_html_tags ==true) {
     $name = strip_html_tags($name);
     $desc = strip_html_tags($desc);
 }

 $name = utf8_encode($name);
 $desc = utf8_encode($desc);
 $link = utf8_encode($link);

 $manufacturer = $row['manufacturers_name'];
 $manufacturer = utf8_encode ($manufacturer);
//  $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));


//    if (tep_not_null($row['specials_new_products_price'])) {
//    $price = tep_add_tax($row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    } else {
//       $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    }

//  if( $discount = tep_get_products_special_price($id) ) {
//    $offer = tep_add_tax($discount, tep_get_tax_rate($row['products_tax_class_id']));
//  } else {
//    $offer = '';
//  }
//add price limit decimals to 2  
//$price = sprintf("%01.2f", $price);

 $cat_name = $row['categories_name'];

 // Encoding to UTF-8
 $cat_name = utf8_encode (replace_problem_characters(strip_html_tags($cat_name)));

 // Setting the URLs to the images and buttons
 $relative_image_url = tep_image(DIR_WS_IMAGES . $image, $name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); // usare funzione per il resize la fuzione base non va !
//  $relative_image_url = str_replace('/>', '', $relative_image_url);
//  $relative_image_url = str_replace('<img src="', '', $relative_image_url);
 $image_url = $relative_image_url;

//  $relative_buy_url = tep_image_button('button_shopping_cart.gif', IMAGE_BUTTON_IN_CART, 'style="margin: 0px;"');
//  $relative_buy_url = str_replace('">', '', $relative_buy_url);
//  $relative_buy_url = str_replace('<img src="', '', $relative_buy_url);
//  $buy_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_buy_url;

//  $relative_button_url = tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO, 'style="margin: 0px;"');
//  $relative_button_url = str_replace('">', '', $relative_button_url);
//  $relative_button_url = str_replace('<img src="', '', $relative_button_url);
//  $button_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_button_url;


 // http://www.w3.org/TR/REC-xml/#dt-chardata
 // The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form
 //$name = str_replace('&','&',$name);
 //$desc = str_replace('&','&',$desc);
 //$link = str_replace('&','&',$link);
 //$cat_name = str_replace('&','&',$cat_name);

 $name = str_replace('<','<',$name);
 $desc = str_replace('<','<',$desc);
 $link = str_replace('<','<',$link);
 $cat_name = str_replace('<','<',$cat_name);

 $name = str_replace('>','>',$name);
 $desc = str_replace('>','>',$desc);
 $link = str_replace('>','>',$link);
 $cat_name = str_replace('>','>',$cat_name);


//  $buy_link = tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $id);
 // Encoding to UTF-8
//  $buy_link = utf8_encode ($buy_link);
//  $buy_link = str_replace('&','&',$buy_link);
//  $buy_link = str_replace('<','<',$buy_link);
//  $buy_link = str_replace('>','>',$buy_link);

 // Writing the output
 echo '<item>' . "\n";
 echo '  <title>' . $name . '</title>' . "\n";
 echo '  <category>' . $cat_name . '</category>' . "\n";
 echo '  <link>' . $link . '</link>' . "\n";
 echo '  <description>'; // . "\n";
 if ($ecommerce=='' && $image != '') {
   echo '<![CDATA[<a href="' . $link . '">' . $image_url . '</a><br />]]>';
 }
 echo $desc;
 if ($ecommerce=='') {
   echo '<![CDATA[<br><b>Manufacturer: </b>' . $manufacturer . ']]>' . "\n";  // delete this line if you do not want to list manufacturer 
   echo '<![CDATA[<br><b>Model #: </b>' . $model . ']]>' . "\n";         // delete this line if you do not want to list model num  
//    echo '<![CDATA[<br><b>Price: </b>$'  . $price . '<br>]]>' . "\n";      // delete this line if you do not want to list price, replace $ = dollars with your currency
//    echo '<![CDATA[<br><br><a href="' .$buy_link. '"><img src="' . $buy_url . '" border="0"</a> ]]>';
//    echo '<![CDATA[<a href="' . $link . '"><img src="' . $button_url . '" /border="0"</a>]]>' . "\n";
 }
 echo '</description>' . "\n";
 echo '  <guid>' . $link . '</guid>' . "\n";
 echo '  <pubDate>' . gmdate("D, d M Y H:i:s", strtotime($added)). ' GMT' . '</pubDate>' . "\n";
 if($ecommerce!='') {
   echo '  <media:thumbnail url="' . $image_url . '">' . $image_url . '</media:thumbnail>' . "\n";
   echo '  <ecommerce:SKU>' . $id . '</ecommerce:SKU>' . "\n";
//    echo '  <ecommerce:listPrice currency="' . DEFAULT_CURRENCY . '">' . $price . '</ecommerce:listPrice>' . "\n";
//    if ($offer) {
//    echo '<![CDATA[<br><b>Price: </b>$'  . $offer . '<br>]]>' . "\n";   // delete this line if you do not want to list price, replace $ = dollars with your currency
//      echo '  <ecommerce:offerPrice currency="' . DEFAULT_CURRENCY . '">' . $offer . '</ecommerce:offerPrice>' . "\n";
//    }
   echo '  <ecommerce:manufacturer>' . $manufacturer . '</ecommerce:manufacturer>' . "\n";
 }
 echo '</item>' . "\n";
}
}

echo '</channel>' . "\n";
echo '</rss>' . "\n";

   /*
    * Include the application_bottom.php script 
    */
   include_once('includes/application_bottom.php');
?>

 

I have removed prices and possiblità of purchase.

I have put the possibility to disable the categories

 

in some it serves it goes in others from error.

I bring an example of error:

w3c feed validator

 

error is .. XML parsing error: <unknown>:27:1: undefined entity

 

does someone have suggestions?

thanks

Share this post


Link to post
Share on other sites

you excuse the grammar, use an on-line translator.

I have modified the code this way:

<?php
/*
 $Id: rss.php,v 2.0 2007/05/12 19:30:06 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

/*
* Include the application_top.php script
*/
require('includes/application_top.php');

$navigation->remove_current_page();

// If the language is not specified
 $lang_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$languages_id . "'");

// Recover the code (fr, en, etc) and the id (1, 2, etc) of the current language
if (tep_db_num_rows($lang_query)) {
 $lang_a = tep_db_fetch_array($lang_query);
   $lang_code = $lang_a['code'];
}

define('RSS_STRIP_HTML_TAGS', false);
// If the default of your catalog is not what you want in your RSS feed, then
// please change this three constants:
// Enter an appropriate title for your website
define('RSS_TITLE', STORE_NAME);
// Enter your main shopping cart link
define('WEBLINK', HTTP_SERVER);
// Enter a description of your shopping cart
define('DESCRIPTION', TITLE);
/////////////////////////////////////////////////////////////
//That's it.  No More Editing (Unless you renamed DB tables or need to switch
//to SEO links (Apache Rewrite URL)
/////////////////////////////////////////////////////////////

$store_name = STORE_NAME;
$rss_title = RSS_TITLE;
$weblink = WEBLINK;
$description = DESCRIPTION;
$email_address = STORE_OWNER_EMAIL_ADDRESS;

$subtitle = '';

function replace_problem_characters($text) {
   $formattags = array("&");
   $replacevals = array("&");
   $text = str_replace($formattags, $replacevals, $text);
  $in[] = '@&(amp|#038);@i'; $out[] = '&';
   $in[] = '@&(#036);@i'; $out[] = '$';
   $in[] = '@&(quot);@i'; $out[] = '"';
   $in[] = '@&(#039);@i'; $out[] = '\'';
   $in[] = '@&(nbsp|#160);@i'; $out[] = ' ';
   $in[] = '@&(hellip|#8230);@i'; $out[] = '...';
   $in[] = '@&(copy|#169);@i'; $out[] = '(c)';
   $in[] = '@&(trade|#129);@i'; $out[] = '(tm)';
   $in[] = '@&(lt|#60);@i'; $out[] = '<';
   $in[] = '@&(gt|#62);@i'; $out[] = '>';
   $in[] = '@&(laquo);@i'; $out[] = '«';
   $in[] = '@&(raquo);@i'; $out[] = '»';
   $in[] = '@&(deg);@i'; $out[] = '°';
   $in[] = '@&(mdash);@i'; $out[] = '—';
   $in[] = '@&(reg);@i'; $out[] = '®';
   $in[] = '@&(–);@i'; $out[] = '-';
   $text = preg_replace($in, $out, $text);
   return $text;
}

function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.

   $search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
                    "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
                    //"'([rn])[s]+'",                // Strip out white space
                    "'&(quot|#34);'i",                // Replace HTML entities
                    // "'&(amp|#38);'i",
                    "'&(lt|#60);'i",
                    "'&(gt|#62);'i",
                    "'&(nbsp|#160);'i",
                    "'&(iexcl|#161);'i",
                    "'&(cent|#162);'i",
                    "'&(pound|#163);'i",
                    "'&(copy|#169);'i",
                    "'(d+);'e");                    // evaluate as php

   $replace = array ("",
                    "",
                    //"\1",
                    "\"",
                    "&",
                    "<",
                    ">",
                    " ",
                    chr(160),
                    chr(161),
                    chr(162),
                    chr(163),
                    chr(169),
                    "chr(\1)");

   return preg_replace($search, $replace, $str);
}


 if(!function_exists('eval_rss_urls')) {
   function eval_rss_urls($string) {
           // rewrite all local urls to absolute urls
       return preg_replace_callback("/(href|src|action)=[\"']{0,1}(\.{0,2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is","rewrite_rss_local_urls",$string);
       //"/(href|src|action)=[\"']{0,1}(\.{2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is"
   }
 } 

     function rewrite_rss_local_urls($string) {

   $repl_text = $string[0];
   $repl_by = HTTP_SERVER.'\\';
   $repl_len = 0;

   $index_pos = strpos  ( $repl_text , '..');
   if ($index_pos > -1) {
       $repl_len = 2;
   } else {
        $index_pos = strpos  ( $repl_text , '\"\\');
       if ($index_pos > -1) {
           $repl_len = 0;
           $index_pos+=1;
       }
   }
   if ($index_pos > -1) {
       substr_replace($repl_text, $repl_by, $index_pos,2 );
   }
       ob_start();
           echo $repl_text;
           $return = ob_get_contents();
          ob_end_clean();
       return $return;
   }

// to strip html or not to strip html tags
if (isset($_GET['html'])) {
   if ($_GET['html']=='false') {
       $strip_html_tags = true;
   } else {
       $strip_html_tags = false;
   }
} else {
   $strip_html_tags = RSS_STRIP_HTML_TAGS;
}

// show the products of a specified manufacturer

   if (isset($_GET['manufacturers_id'])) {

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {

// We are asked to show only a specific category

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id  left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id']  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";


     }

     $subtitle = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['manufacturers_name'];
       $rss_title = BOX_INFORMATION_RSS_MANUFACTURER;
   } else if (tep_not_null($current_category_id)) {

// show the products in a given categorie

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' 
              and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";
     }

       $subtitle= tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['categories_name'];
        $rss_title = BOX_INFORMATION_RSS_CATEGORY;

   } else {

       // show realy al products
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "'  
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

       $rss_title = BOX_INFORMATION_RSS;
   }
//    echo $listing_sql;
// Execute SQL query and get result
$query = tep_db_query($listing_sql);

   /*
    * If there are returned rows...
    * Basic sanity check 
    */
   if ( tep_db_num_rows($query) > 0 ){

if ($subtitle != '') $rss_title .= ' - '.$subtitle;

// Encoding to UTF-8
$store_name =  utf8_encode (replace_problem_characters($store_name));
$rss_title =  utf8_encode (replace_problem_characters($rss_title));
$weblink =  utf8_encode ($weblink);
$description =  utf8_encode ($description);
$email_address =  utf8_encode ($email_address);

   // SQL header(Last-Modified)
$last_modified = '';
$sql = "SELECT MAX(products_date_added) as mPla, MAX(products_last_modified) as mPlm FROM " . TABLE_PRODUCTS. " WHERE products_to_rss = '1' ORDER BY products_id DESC LIMIT 1";
 $sql_result = tep_db_query($sql);
   $row = tep_db_fetch_array($sql_result);

   if ($row['mPlm'] != '') { $last_modified = $row['mPlm']; }
   else { $last_modified = $row['mpla']; }

 if(!function_exists('getallheaders')){
       function getallheaders(){
           settype($headers,'array');
           foreach($_SERVER as $h => $v){
               if(preg_match('/HTTP_(.+)/',$h,$hp)){
                   $headers[$hp[1]] = $v;
               }
           }
           return $headers;
       }
 }

$headers = getallheaders(); 

 $refresh = 1; // refresca por defecto 
 $etag = md5($last_modified);

 if(isset($headers["If-Modified-Since"])) { // Verificamos fecha enviada por el lector RSS
     $since = strtotime($headers["If-Modified-Since"]); 
   if($since >= strtotime($last_modified)) { $refresh = 0; }
 } 

 if(isset($headers["If-None-Match"])) { // Verificamos el ETag
     if(strcmp($headers["If-None-Match"], $etag) == 0) {
     $refresh = 0;
   } else {
     $refresh = 1;
   }
 }

 if($refresh == 0) {
   header("HTTP/1.1 304 Not changed");
   // La primera línea de los headers debe ser el status
   // sino el Netcrap se lía y da "No Data"
   ob_end_clean(); // Descartamos los contenidos del búfer de salida en cola y lo deshabilitamos
 }


// Begin sending of the data
@header('Content-Type: application/rss+xml; charset=UTF-8');

//header("Last-Modified: " . tep_date_raw($last_modified));
@header('Last-Modified: ' .gmdate("D, d M Y G:i:s", strtotime($last_modified)). ' GMT');
//header('Last-Modified: ' .gmdate("D, d M Y G:i:s T",strtotime($last_modified)) . ' GMT');
@header("ETag: " . md5($etag));
echo '<!-- RSS for ' . $store_name . ', generated on ' . gmdate("D, d M Y G:i:s", strtotime($last_modified)) . ' GMT'. ' -->' . "\n";
$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0">
<channel>
<title><?php echo utf8_encode($rss_title); ?></title>
<link><?php echo $weblink;?></link>
<description><?php echo utf8_encode($description); ?></description>
<!--<atom:link href="<?php echo tep_href_link(FILENAME_RSS, $_SERVER['QUERY_STRING'] = str_replace('&','&',$_SERVER['QUERY_STRING']), 'NONSSL', false ); ?>" rel="self" type="application/rss+xml" /> Remove comments if you want this to remain -->
<webMaster><?php echo $email_address . ' (' .STORE_OWNER.')'; ?></webMaster>
<language><?php echo $lang_code; ?></language>
<lastBuildDate><?php echo gmdate("D, d M Y H:i:s", strtotime($last_modified)). ' GMT'; ?></lastBuildDate>
<image>
 <url><?php echo $weblink . DIR_WS_CATALOG . bts_select(images, 'logo_rss.png'); ?></url> 
 <title><?php // echo utf8_encode($rss_title); // 
             ?><?php echo utf8_encode($store_name); ?></title>
 <link><?php echo $weblink;?></link>
 <description><?php echo utf8_encode($description); ?></description>
 <width>100</width>
 <height>50</height>
</image>
<copyright>Copyright reserved</copyright> 
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php
// Format results by row
while( $row = tep_db_fetch_array($query) ){
 $id = $row['products_id'];

 // RSS Links for Ultimate SEO (Gareth Houston 10 May 2005)
 $link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id, 'NONSSL', false);

 $model = $row['products_model'];
 $image = $row['products_image'];
 $added = date(r,strtotime($row['products_date_added']));

 // Setting and cleaning the data
 $name = $row['products_name'];
 $desc = eval_rss_urls($row['products_description']);

 // Encoding to UTF-8  
 if ($strip_html_tags ==true) {
     $name = strip_html_tags($name);
     $desc = strip_html_tags($desc);
 }

 $name = utf8_encode($name);
 $desc = utf8_encode($desc);
 $link = utf8_encode($link);

 $manufacturer = $row['manufacturers_name'];
 $manufacturer = utf8_encode ($manufacturer);
//  $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));


//    if (tep_not_null($row['specials_new_products_price'])) {
//    $price = tep_add_tax($row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    } else {
//       $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    }

//  if( $discount = tep_get_products_special_price($id) ) {
//    $offer = tep_add_tax($discount, tep_get_tax_rate($row['products_tax_class_id']));
//  } else {
//    $offer = '';
//  }
//add price limit decimals to 2  
//$price = sprintf("%01.2f", $price);

 $cat_name = $row['categories_name'];

 // Encoding to UTF-8
 $cat_name = utf8_encode (replace_problem_characters(strip_html_tags($cat_name)));

 // Setting the URLs to the images and buttons
 $relative_image_url = tep_image(DIR_WS_IMAGES . $image, $name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); // usare funzione per il resize la fuzione base non va !
//  $relative_image_url = str_replace('/>', '', $relative_image_url);
//  $relative_image_url = str_replace('<img src="', '', $relative_image_url);
 $image_url = $relative_image_url;

//  $relative_buy_url = tep_image_button('button_shopping_cart.gif', IMAGE_BUTTON_IN_CART, 'style="margin: 0px;"');
//  $relative_buy_url = str_replace('">', '', $relative_buy_url);
//  $relative_buy_url = str_replace('<img src="', '', $relative_buy_url);
//  $buy_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_buy_url;

//  $relative_button_url = tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO, 'style="margin: 0px;"');
//  $relative_button_url = str_replace('">', '', $relative_button_url);
//  $relative_button_url = str_replace('<img src="', '', $relative_button_url);
//  $button_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_button_url;


 // http://www.w3.org/TR/REC-xml/#dt-chardata
 // The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form
 //$name = str_replace('&','&',$name);
 //$desc = str_replace('&','&',$desc);
 //$link = str_replace('&','&',$link);
 //$cat_name = str_replace('&','&',$cat_name);

 $name = str_replace('<','<',$name);
 $desc = str_replace('<','<',$desc);
 $link = str_replace('<','<',$link);
 $cat_name = str_replace('<','<',$cat_name);

 $name = str_replace('>','>',$name);
 $desc = str_replace('>','>',$desc);
 $link = str_replace('>','>',$link);
 $cat_name = str_replace('>','>',$cat_name);


//  $buy_link = tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $id);
 // Encoding to UTF-8
//  $buy_link = utf8_encode ($buy_link);
//  $buy_link = str_replace('&','&',$buy_link);
//  $buy_link = str_replace('<','<',$buy_link);
//  $buy_link = str_replace('>','>',$buy_link);

 // Writing the output
 echo '<item>' . "\n";
 echo '  <title>' . $name . '</title>' . "\n";
 echo '  <category>' . $cat_name . '</category>' . "\n";
 echo '  <link>' . $link . '</link>' . "\n";
 echo '  <description>'; // . "\n";
 if ($ecommerce=='' && $image != '') {
   echo '<![CDATA[<a href="' . $link . '">' . $image_url . '</a><br />]]>';
 }
 echo $desc;
 if ($ecommerce=='') {
   echo '<![CDATA[<br><b>Manufacturer: </b>' . $manufacturer . ']]>' . "\n";  // delete this line if you do not want to list manufacturer 
   echo '<![CDATA[<br><b>Model #: </b>' . $model . ']]>' . "\n";         // delete this line if you do not want to list model num  
//    echo '<![CDATA[<br><b>Price: </b>$'  . $price . '<br>]]>' . "\n";      // delete this line if you do not want to list price, replace $ = dollars with your currency
//    echo '<![CDATA[<br><br><a href="' .$buy_link. '"><img src="' . $buy_url . '" border="0"</a> ]]>';
//    echo '<![CDATA[<a href="' . $link . '"><img src="' . $button_url . '" /border="0"</a>]]>' . "\n";
 }
 echo '</description>' . "\n";
 echo '  <guid>' . $link . '</guid>' . "\n";
 echo '  <pubDate>' . gmdate("D, d M Y H:i:s", strtotime($added)). ' GMT' . '</pubDate>' . "\n";
 if($ecommerce!='') {
   echo '  <media:thumbnail url="' . $image_url . '">' . $image_url . '</media:thumbnail>' . "\n";
   echo '  <ecommerce:SKU>' . $id . '</ecommerce:SKU>' . "\n";
//    echo '  <ecommerce:listPrice currency="' . DEFAULT_CURRENCY . '">' . $price . '</ecommerce:listPrice>' . "\n";
//    if ($offer) {
//    echo '<![CDATA[<br><b>Price: </b>$'  . $offer . '<br>]]>' . "\n";   // delete this line if you do not want to list price, replace $ = dollars with your currency
//      echo '  <ecommerce:offerPrice currency="' . DEFAULT_CURRENCY . '">' . $offer . '</ecommerce:offerPrice>' . "\n";
//    }
   echo '  <ecommerce:manufacturer>' . $manufacturer . '</ecommerce:manufacturer>' . "\n";
 }
 echo '</item>' . "\n";
}
}

echo '</channel>' . "\n";
echo '</rss>' . "\n";

   /*
    * Include the application_bottom.php script 
    */
   include_once('includes/application_bottom.php');
?>

 

I have removed prices and possiblità of purchase.

I have put the possibility to disable the categories

 

in some it serves it goes in others from error.

I bring an example of error:

w3c feed validator

 

error is .. XML parsing error: <unknown>:27:1: undefined entity

 

does someone have suggestions?

thanks

 

 

Thanks man, after comparing your code to mine I was able to fix my issue with the unwanted charactors!

now just need to fix the issue of top catagories not showing and I'll be happy..

Sorry cant help with your problem.

Share this post


Link to post
Share on other sites

I now have this great mod working well, even the unwanted charactors but theres one major issue for me that I need to sort out and that is the Top and Sub Catagories issue.

 

I see this has been asked about here several times but nobody has addressed it and I think its important.

 

- Top Category feeds not displaying when Top category has sub-categories (sub-categories show fine).

Example:

Category 1 ===> displays fine

Category 2 ===> DOESN'T DISPLAY

L Sub-Category 1 ===> displays fine

L Sub-Category 2 ===> displays fine

Category 3 ===> displays fine

Category 4 ===> DOESN'T DISPLAY

L Sub-Category 1 ===> displays fine

L Sub-Category 2 ===> displays fine

 

 

Does anybody know how to fix this as its each of the Top Catagories that I want the feeds from NOT the sub catagories?

Edited by gameznet

Share this post


Link to post
Share on other sites

resolved

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2000 - 2011 osCommerce

 Released under the GNU General Public License
*/

require('includes/application_top.php');

$navigation->remove_current_page();

// If the language is not specified
 $lang_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$languages_id . "'");

// Recover the code (fr, en, etc) and the id (1, 2, etc) of the current language
if (tep_db_num_rows($lang_query)) {
 $lang_a = tep_db_fetch_array($lang_query);
   $lang_code = $lang_a['code'];
}

define('RSS_STRIP_HTML_TAGS', false);
// If the default of your catalog is not what you want in your RSS feed, then
// please change this three constants:
// Enter an appropriate title for your website
define('RSS_TITLE', STORE_NAME);
// Enter your main shopping cart link
define('WEBLINK', HTTP_SERVER);
// Enter a description of your shopping cart
define('DESCRIPTION', TITLE);
/////////////////////////////////////////////////////////////
//That's it.  No More Editing (Unless you renamed DB tables or need to switch
//to SEO links (Apache Rewrite URL)
/////////////////////////////////////////////////////////////

$store_name = STORE_NAME;
$rss_title = RSS_TITLE;
$weblink = WEBLINK;
$description = DESCRIPTION;
$email_address = STORE_OWNER_EMAIL_ADDRESS;

$subtitle = '';

function replace_problem_characters($text) {
   $formattags = array("&");
   $replacevals = array("&");
   $text = str_replace($formattags, $replacevals, $text);
   $in[] = '@&(amp|#038);@i'; $out[] = '&';
   $in[] = '@&(#036);@i'; $out[] = '$';
   $in[] = '@&(quot);@i'; $out[] = '"';
   $in[] = '@&(#039);@i'; $out[] = '\'';
   $in[] = '@&(nbsp|#160);@i'; $out[] = ' ';
   $in[] = '@&(hellip|#8230);@i'; $out[] = '...';
   $in[] = '@&(copy|#169);@i'; $out[] = '(c)';
   $in[] = '@&(trade|#129);@i'; $out[] = '(tm)';
   $in[] = '@&(lt|#60);@i'; $out[] = '<';
   $in[] = '@&(gt|#62);@i'; $out[] = '>';
   $in[] = '@&(laquo);@i'; $out[] = '«';
   $in[] = '@&(raquo);@i'; $out[] = '»';
   $in[] = '@&(deg);@i'; $out[] = '°';
   $in[] = '@&(mdash);@i'; $out[] = '—';
   $in[] = '@&(reg);@i'; $out[] = '®';
   $in[] = '@&(–);@i'; $out[] = '-';
   $text = preg_replace($in, $out, $text);
   return $text;
}

function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.

   $search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
                    "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
                    //"'([rn])[s]+'",                // Strip out white space
                    "'&(quot|#34);'i",                // Replace HTML entities
                    "'&(amp|#38);'i",
                    "'&(lt|#60);'i",
                    "'&(gt|#62);'i",
                    "'&(nbsp|#160);'i",
                    "'&(iexcl|#161);'i",
                    "'&(cent|#162);'i",
                    "'&(pound|#163);'i",
                    "'&(copy|#169);'i",
                    "'(d+);'e");                    // evaluate as php

   $replace = array ("",
                    "",
                    //"\1",
                    "\"",
                    "&",
                    "<",
                    ">",
                    " ",
                    chr(160),
                    chr(161),
                    chr(162),
                    chr(163),
                    chr(169),
                    "chr(\1)");

   return preg_replace($search, $replace, $str);
}


 if(!function_exists('eval_rss_urls')) {
   function eval_rss_urls($string) {
           // rewrite all local urls to absolute urls
       return preg_replace_callback("/(href|src|action)=[\"']{0,1}(\.{0,2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is","rewrite_rss_local_urls",$string);
       //"/(href|src|action)=[\"']{0,1}(\.{2}[\\|\/]{1})(.*?)[\"']{0,1}( .*?){0,1}>/is"
   }
 } 

     function rewrite_rss_local_urls($string) {

   $repl_text = $string[0];
   $repl_by = HTTP_SERVER.'\\';
   $repl_len = 0;

   $index_pos = strpos  ( $repl_text , '..');
   if ($index_pos > -1) {
       $repl_len = 2;
   } else {
        $index_pos = strpos  ( $repl_text , '\"\\');
       if ($index_pos > -1) {
           $repl_len = 0;
           $index_pos+=1;
       }
   }
   if ($index_pos > -1) {
       substr_replace($repl_text, $repl_by, $index_pos,2 );
   }
       ob_start();
           echo $repl_text;
           $return = ob_get_contents();
          ob_end_clean();
       return $return;
   }

// to strip html or not to strip html tags
if (isset($_GET['html'])) {
   if ($_GET['html']=='false') {
       $strip_html_tags = true;
   } else {
       $strip_html_tags = false;
   }
} else {
   $strip_html_tags = RSS_STRIP_HTML_TAGS;
}

// show the products of a specified manufacturer

   if (isset($_GET['manufacturers_id'])) {

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {

// We are asked to show only a specific category

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {

// We show them all

       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id  left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id']  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";


     }

     $subtitle = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['manufacturers_name'];
       $rss_title = BOX_INFORMATION_RSS_MANUFACTURER;
   } else if (tep_not_null($current_category_id)) {

// show the products in a given categorie

     if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' 
              and p2c.categories_id = '" . (int)$current_category_id  . "' 
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";
     }

       $subtitle= tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
     $subtitle = tep_db_fetch_array($subtitle);
     $subtitle = $subtitle['categories_name'];
        $rss_title = BOX_INFORMATION_RSS_CATEGORY;

   } else {

       // show realy al products
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_model, p.products_price, p.products_image, p.products_date_added, pd.products_name, pd.products_description,
              m.manufacturers_name, cd.categories_name, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd
              on p2c.categories_id = cd.categories_id left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and p.products_status = '1' and p.products_to_rss='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "'  
              GROUP BY p.products_id
       ORDER BY p.products_id DESC
       LIMIT ". (int)MAX_RSS_ARTICLES."";

       $rss_title = BOX_INFORMATION_RSS;
   }
//    echo $listing_sql;
// Execute SQL query and get result
$query = tep_db_query($listing_sql);

   /*
    * If there are returned rows...
    * Basic sanity check 
    */
   if ( tep_db_num_rows($query) > 0 ){

if ($subtitle != '') $rss_title .= ' - '.$subtitle;

// Encoding to UTF-8
$store_name =  utf8_encode (replace_problem_characters($store_name));
$rss_title =  utf8_encode (replace_problem_characters($rss_title));
$weblink =  utf8_encode ($weblink);
$description =  utf8_encode (replace_problem_characters($description));
$email_address =  utf8_encode ($email_address);

   // SQL header(Last-Modified)
$last_modified = '';
$sql = "SELECT MAX(products_date_added) as mPla, MAX(products_last_modified) as mPlm FROM " . TABLE_PRODUCTS. " WHERE products_to_rss = '1' ORDER BY products_id DESC LIMIT 1";
 $sql_result = tep_db_query($sql);
   $row = tep_db_fetch_array($sql_result);

   if ($row['mPlm'] != '') { $last_modified = $row['mPlm']; }
   else { $last_modified = $row['mpla']; }

 if(!function_exists('getallheaders')){
       function getallheaders(){
           settype($headers,'array');
           foreach($_SERVER as $h => $v){
               if(preg_match('/HTTP_(.+)/',$h,$hp)){
                   $headers[$hp[1]] = $v;
               }
           }
           return $headers;
       }
 }

$headers = getallheaders(); 

 $refresh = 1; // refresca por defecto 
 $etag = md5($last_modified);

 if(isset($headers["If-Modified-Since"])) { // Verificamos fecha enviada por el lector RSS
     $since = strtotime($headers["If-Modified-Since"]); 
   if($since >= strtotime($last_modified)) { $refresh = 0; }
 } 

 if(isset($headers["If-None-Match"])) { // Verificamos el ETag
     if(strcmp($headers["If-None-Match"], $etag) == 0) {
     $refresh = 0;
   } else {
     $refresh = 1;
   }
 }

 if($refresh == 0) {
   header("HTTP/1.1 304 Not changed");
   // La primera línea de los headers debe ser el status
   // sino el Netcrap se lía y da "No Data"
   ob_end_clean(); // Descartamos los contenidos del búfer de salida en cola y lo deshabilitamos
 }


// Begin sending of the data
@header('Content-Type: application/rss+xml; charset=UTF-8');
//header("Last-Modified: " . tep_date_raw($last_modified));
@header('Last-Modified: ' .gmdate("D, d M Y G:i:s", strtotime($last_modified)). ' GMT');
//header('Last-Modified: ' .gmdate("D, d M Y G:i:s T",strtotime($last_modified)) . ' GMT');
@header("ETag: " . md5($etag));
echo '<!-- RSS for ' . $store_name . ', generated on ' . gmdate("D, d M Y G:i:s", strtotime($last_modified)) . ' GMT'. ' -->' . "\n";
$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss version="2.0"
 xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:ecommerce="http://shopping.discovery.com/erss/"
 xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title><?php echo utf8_encode($rss_title); ?></title>
<link><?php echo $weblink;?></link>
<description><?php echo utf8_encode($description); ?></description>
<!--<atom:link href="<?php echo tep_href_link(FILENAME_RSS, $_SERVER['QUERY_STRING'] = str_replace('&','&',$_SERVER['QUERY_STRING']), 'NONSSL', false ); ?>" rel="self" type="application/rss+xml" /> Remove comments if you want this to remain -->
<webMaster><?php echo $email_address . ' (' .STORE_OWNER.')'; ?></webMaster>
<language><?php echo $lang_code; ?></language>
<lastBuildDate><?php echo gmdate("D, d M Y H:i:s", strtotime($last_modified)). ' GMT'; ?></lastBuildDate>
<image>
 <url><?php echo $weblink . DIR_WS_CATALOG . bts_select(images, 'logo_rss.png'); ?></url> 
 <title><?php // echo utf8_encode($rss_title); // ?><?php echo utf8_encode($store_name); ?></title>
 <link><?php echo $weblink;?></link>
 <description><?php echo utf8_encode($description); ?></description>
 <width>100</width>
 <height>50</height>
</image>
<copyright>Copyright reserved</copyright> 
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php
// Format results by row
while( $row = tep_db_fetch_array($query) ){
 $id = $row['products_id'];

 // RSS Links for Ultimate SEO (Gareth Houston 10 May 2005)
 $link = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $id, 'NONSSL', false);

 $model = $row['products_model'];
 $image = $row['products_image'];
 $added = date(r,strtotime($row['products_date_added']));

 // Setting and cleaning the data
 $name = $row['products_name'];
 $desc = eval_rss_urls($row['products_description']);

 // Encoding to UTF-8  
 if ($strip_html_tags ==true) {
     $name = strip_html_tags($name);
     $desc = strip_html_tags($desc);
 }

 $name = utf8_encode(replace_problem_characters($name));
 $desc = utf8_encode(replace_problem_characters($desc));
 $link = utf8_encode($link);

 $manufacturer = $row['manufacturers_name'];
 $manufacturer = utf8_encode ($manufacturer);
//  $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));


//    if (tep_not_null($row['specials_new_products_price'])) {
//    $price = tep_add_tax($row['specials_new_products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    } else {
//       $price = tep_add_tax($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));
//    }

//  if( $discount = tep_get_products_special_price($id) ) {
//    $offer = tep_add_tax($discount, tep_get_tax_rate($row['products_tax_class_id']));
//  } else {
//    $offer = '';
//  }
//add price limit decimals to 2  
//$price = sprintf("%01.2f", $price);

 $cat_name = $row['categories_name'];

 // Encoding to UTF-8
 $cat_name = utf8_encode (replace_problem_characters(strip_html_tags($cat_name)));

 // Setting the URLs to the images and buttons
 $relative_image_url = tep_image(DIR_WS_IMAGES . $image, $name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); // usare funzione per il resize la fuzione base non va !
//  $relative_image_url = str_replace('/>', '', $relative_image_url);
//  $relative_image_url = str_replace('<img src="', '', $relative_image_url);
 $image_url = $relative_image_url;

//  $relative_buy_url = tep_image_button('button_shopping_cart.gif', IMAGE_BUTTON_IN_CART, 'style="margin: 0px;"');
//  $relative_buy_url = str_replace('">', '', $relative_buy_url);
//  $relative_buy_url = str_replace('<img src="', '', $relative_buy_url);
//  $buy_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_buy_url;

//  $relative_button_url = tep_image_button('button_more_info.gif', IMAGE_BUTTON_MORE_INFO, 'style="margin: 0px;"');
//  $relative_button_url = str_replace('">', '', $relative_button_url);
//  $relative_button_url = str_replace('<img src="', '', $relative_button_url);
//  $button_url = HTTP_SERVER . DIR_WS_CATALOG . $relative_button_url;


 // http://www.w3.org/TR/REC-xml/#dt-chardata
 // The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form
 //$name = str_replace('&','&',$name);
 //$desc = str_replace('&','&',$desc);
 //$link = str_replace('&','&',$link);
 //$cat_name = str_replace('&','&',$cat_name);

 $name = str_replace('<','<',$name);
 $desc = str_replace('<','<',$desc);
 $link = str_replace('<','<',$link);
 $cat_name = str_replace('<','<',$cat_name);

 $name = str_replace('>','>',$name);
 $desc = str_replace('>','>',$desc);
 $link = str_replace('>','>',$link);
 $cat_name = str_replace('>','>',$cat_name);


//  $buy_link = tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $id);
 // Encoding to UTF-8
//  $buy_link = utf8_encode ($buy_link);
//  $buy_link = str_replace('&','&',$buy_link);
//  $buy_link = str_replace('<','<',$buy_link);
//  $buy_link = str_replace('>','>',$buy_link);

 // Writing the output
 echo '<item>' . "\n";
 echo '  <title>' . $name . '</title>' . "\n";
 echo '  <category>' . $cat_name . '</category>' . "\n";
 echo '  <link>' . $link . '</link>' . "\n";
 echo '  <description>'; // . "\n";
 if ($ecommerce=='' && $image != '') {
   echo '<![CDATA[<a href="' . $link . '">' . $image_url . '</a><br />]]>';
 }
 echo $desc;
 if ($ecommerce=='') {
   echo '<![CDATA[<br><b>Manufacturer: </b>' . $manufacturer . ']]>' . "\n";  // delete this line if you do not want to list manufacturer 
   echo '<![CDATA[<br><b>Model #: </b>' . $model . ']]>' . "\n";         // delete this line if you do not want to list model num  
//    echo '<![CDATA[<br><b>Price: </b>$'  . $price . '<br>]]>' . "\n";      // delete this line if you do not want to list price, replace $ = dollars with your currency
//    echo '<![CDATA[<br><br><a href="' .$buy_link. '"><img src="' . $buy_url . '" border="0"</a> ]]>';
//    echo '<![CDATA[<a href="' . $link . '"><img src="' . $button_url . '" /border="0"</a>]]>' . "\n";
 }
 echo '</description>' . "\n";
 echo '  <guid>' . $link . '</guid>' . "\n";
 echo '  <pubDate>' . gmdate("D, d M Y H:i:s", strtotime($added)). ' GMT' . '</pubDate>' . "\n";
 if($ecommerce!='') {
   echo '  <media:thumbnail url="' . $image_url . '">' . $image_url . '</media:thumbnail>' . "\n";
   echo '  <ecommerce:SKU>' . $id . '</ecommerce:SKU>' . "\n";
//    echo '  <ecommerce:listPrice currency="' . DEFAULT_CURRENCY . '">' . $price . '</ecommerce:listPrice>' . "\n";
//    if ($offer) {
//    echo '<![CDATA[<br><b>Price: </b>$'  . $offer . '<br>]]>' . "\n";   // delete this line if you do not want to list price, replace $ = dollars with your currency
//      echo '  <ecommerce:offerPrice currency="' . DEFAULT_CURRENCY . '">' . $offer . '</ecommerce:offerPrice>' . "\n";
//    }
   echo '  <ecommerce:manufacturer>' . $manufacturer . '</ecommerce:manufacturer>' . "\n";
 }
 echo '</item>' . "\n";
}
}

echo '</channel>' . "\n";
echo '</rss>' . "\n";

   /*
    * Include the application_bottom.php script 
    */
   include_once('includes/application_bottom.php');
?>

 

I have disabled the prices in how much they didn't interest me

Share this post


Link to post
Share on other sites

does this mode work with STS?

 

I've installed v2.2 but figure some of the steps are contradictory to how my templates work. My footer is in the STS template, don't think footer.php is being used (step 7), and when I add the code to the head of any root pages (step 6) e.g. index.php I don't get any feed recognized by IE.

 

i have left optional steps 8 & 9 for now until i am happy the contrib is working. to be honest i'm not even sure what the result should be. I can see in admin that I can set the RSS icon in color or greyed out, and can set the maximum number of items in the feed, but not sure what to expect on client side seeing as I can't get a link in my footer. The code for the footer.php file does not work if pasted into my sts template either, but that's not surprising.

 

if i point my browser to rss.php then IE just says "Internet Explorer cannot display this feed", "Internet Explorer does not support feeds with DTDs."

Edited by midijay

Share this post


Link to post
Share on other sites

a further look shows that the feed being generated is nothing like a feed at all, rss.php is producing a webpage that looks like my site but with no content in the main frame. I'm guessing the issue it STS so the real question here is can it work with STS

Share this post


Link to post
Share on other sites

ok i found in this thread the help i needed to get this working with STS so please ignore my previous 2 posts, but I do have 1 new question.

 

IE now recognizes the main feed on my pages, that is the feed with ALL products in it.

 

however, if i go to a category, then there is the rss button below the product listing with a link to the feed for the category, but IE is only recognizing the main feed on the page. I'm presuming it should show 2 feeds, the main one (linked to in my footer) and the one for this category?

 

Maybe that's not how it works and I already have full functionality.

Share this post


Link to post
Share on other sites

I've been using this contribution for several years now and love it! The work is GREATLY appreciated! RSS helps with SEO for me, so this was a contribution was a nice add-on.

 

I do have a slight problem currently.

 

I recently moved my store to another host/server and I noticed the RSS feed is not working since I moved the site. I am getting the following error:

 

Fatal error: Call to undefined function getallheaders() in (address removed)

 

I moved the site by uploading all the files and imported the database.

 

It was mentioned in another post that an error like that could be whitespace in the code, but I am using files that worked fine before, I did not edit any code, so I don't see how they could be it.

 

I double checked the instructions, thinking maybe I missed a permission setting or something, but did not find anything.

 

What could I have missed in the move?

 

Any help would be appreciated so I can get this working again.

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

×