RSS Feed v1.22.2

Questo forum è dedicato alle discussioni riguardanti le contribution per osCommerce

Moderatore: mod Generali

Rispondi
Avatar utente
Spiderweb
membro Veteran
membro Veteran
Messaggi: 573
Iscritto il: 28/09/2005, 22:09
Località: Toscana

RSS Feed v1.22.2

Messaggio da Spiderweb »

Ciao,
per caso qualcuno ha installato e usa questa contribution: RSS Feed v1.22.2 (http://www.oscommerce.com/community/con ... earch,feed) ?

Io ho finito di installarla adesso in locale e con Firefox mi funziona mentre con I.E. no.... :roll:

Con Firefox cliccando sull'icona del feed mi si apre correttamente la pagina generata in automatico dal file rss.php, impaginata perfettamente con testo e immagini, con I.E. invece vedo una parte del codice sorgente in una pagina di solo testo.

Per adesso non ho fatto prove in remoto perchè prima di mettere online i files modificati volevo essere sicuro se funzionava, non penso sia questo il problema.

Spero arrivino risposte :wink:

Ciao, Stefano
Prima di postare leggetevi le FAQ: viewtopic.php?t=3259
Avatar utente
Spiderweb
membro Veteran
membro Veteran
Messaggi: 573
Iscritto il: 28/09/2005, 22:09
Località: Toscana

Messaggio da Spiderweb »

Ho scoperto che con I.E. versione 7 funziona tutto bene, il problema me lo dava con la 6, però mi piacerebbe capire come si può risolvere ugualmente la cosa visto che ci sono in giro sempre molti utenti che non hanno aggiornato il browser all'ultima versione.

Sul forum ufficiale di Oscommerce (http://forums.oscommerce.com/index.php? ... 45&hl=feed) ho trovato la discussione che parla di questa contribution e fa riferimento anche a questo problema, però non c'ho capito molto... qualcuno dice di fare un mix tra la nuova e la vecchia versione e dovrebbe funzionare, mah?

Per adesso io la installo così, se poi riesco a capirci qualcosa o arriva qualcuno più esperto di me in materia è meglio :wink:
Prima di postare leggetevi le FAQ: viewtopic.php?t=3259
maury2ma
membro Master
membro Master
Messaggi: 1669
Iscritto il: 10/02/2006, 14:04
Contatta:

Messaggio da maury2ma »

continuo questo topic per non aprirne un altro.

qualcuno e' riuscito ad installarlo con i prefissi alle tabelle ?

allego il codice della pagina rss.php
non capisco dove non funziona, ma con i prefissi s'impianta senza i prefissi funziona, malissimo ma funziona .

Codice: Seleziona tutto

<?php
/*
  $Id: rss.php,v 1.22 2007/04/13 13:04:02 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

require('includes/application_top.php');

$navigation->remove_current_page();

$connection = tep_db_connect() or die('Unable to connect to database server!');
// Select database
//$db = mysql_select_db(DB_DATABASE, $connection) or die(mysql_error());

// If the language is not specified
if ($_GET['language'] == '') {
  $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where directory = \'' . $language . '\'');
} else {
  $cur_language = tep_db_output($_GET['language']);
  $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where code = \'' . $cur_language . '\'');
}

// 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'];
    $lang_id = $lang_a['languages_id'];
}

// 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;

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

// Begin sending of the data
Header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n";
echo '<!-- RSS for ' . $store_name . ', generated on ' . date(r) . ' -->' . "\n";
?>
<rss version="2.0"
  xmlns:ecommerce="http://shopping.discovery.com/erss/"
  xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title><?php echo $rss_title; ?></title>
<link><?php echo $weblink;?></link>
<description><?php echo $description; ?></description>
<webMaster><?php echo $email_address; ?></webMaster>
<language><?php echo $lang_code; ?></language>
<lastBuildDate><?php echo date(r); ?></lastBuildDate>
<image>
  <url><?php echo $weblink . '/images/rss_logo.jpg';?></url>
  <title><?php echo $rss_title; ?></title>
  <link><?php echo $weblink;?></link>
  <description><?php echo $description; ?></description>
</image>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php

// Create SQL statement
$category = preg_replace('/[^0-9_]/', '', $_GET['cPath']);
$ecommerce = $_GET['ecommerce'];
if ($category != '') {
  // Check to see if we are in a subcategory
  if (strrpos($category, '_') > 0) {
    $category = substr($category, strrpos($category, '_') + 1, strlen($category));
  }
  $catTable = ", products_to_categories pc ";
  $catWhere = 'p.products_id = pc.products_id AND pc.categories_id = \'' . $category . '\' AND ';
}

$sql = "SELECT p.products_id, p.products_price, p.products_tax_class_id, p.products_model, 
               p.products_image, p.products_date_added, pd.products_name, pd.products_description,
               m.manufacturers_name, cd.categories_name
        FROM products p
             $catTable
        LEFT JOIN products_description pd
               ON pd.products_id = p.products_id
              AND pd.language_id = '$lang_id'
        LEFT JOIN manufacturers m
               ON m.manufacturers_id = p.manufacturers_id
        LEFT JOIN products_to_categories p2c
               ON p2c.products_id=p.products_id
        LEFT JOIN categories_description cd
               ON p2c.categories_id = cd.categories_id
              AND cd.language_id = '$lang_id'
        WHERE $catWhere
              p.products_status=1 AND 
              p.products_to_rss=1
        GROUP BY p.products_id
        ORDER BY p.products_id DESC
        LIMIT " . MAX_RSS_ARTICLES;

// Execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die("Couldn\'t execute query:<br />$sql");

// Format results by row
while ($row = mysql_fetch_array($sql_result)) {
  $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 = $row['products_description'];

  // Encoding to UTF-8
  $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( $discount = tep_get_products_special_price($id) ) {
    $offer = tep_add_tax($discount, tep_get_tax_rate($row['products_tax_class_id']));
  } else {
    $offer = '';
  }

  $cat_name = $row['categories_name'];

  // Encoding to UTF-8
  $cat_name = utf8_encode ($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 . $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 . '"><img src="' . $image_url . '"></a>]]>';
  }
  echo $desc;
  if ($ecommerce=='') {
    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>' . $added . '</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 '  <ecommerce:offerPrice currency="' . DEFAULT_CURRENCY . '">' . $offer . '</ecommerce:offerPrice>' . "\n";
    }
    echo '  <ecommerce:manufacturer>' . $manufacturer . '</ecommerce:manufacturer>' . "\n";
  }
  echo '</item>' . "\n";
}
// Free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
</channel>
</rss>
maury2ma
membro Master
membro Master
Messaggi: 1669
Iscritto il: 10/02/2006, 14:04
Contatta:

Messaggio da maury2ma »

risolto, ho semplificato parecchio il codice.

Codice: Seleziona tutto

<?php
/*
  $Id: rss.php,v 1.22 2007/04/13 13:04:02 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

require('includes/application_top.php');

$navigation->remove_current_page();

$connection = tep_db_connect() or die('Unable to connect to database server!');

// If the language is not specified
if ($_GET['language'] == '') {
  $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where directory = \'' . $language . '\'');
} else {
  $cur_language = tep_db_output($_GET['language']);
  $lang_query = tep_db_query('select languages_id, code from ' . TABLE_LANGUAGES . ' where code = \'' . $cur_language . '\'');
}

// 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'];
    $lang_id = $lang_a['languages_id'];
}

// 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;

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

// Begin sending of the data
Header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<?xml-stylesheet href="http://www.w3.org/2000/08/w3c-synd/style.css" type="text/css"?>' . "\n";
echo '<!-- RSS for ' . $store_name . ', generated on ' . date(r) . ' -->' . "\n";
?>
<rss version="2.0"
  xmlns:ecommerce="http://shopping.discovery.com/erss/"
  xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title><?php echo $rss_title; ?></title>
<link><?php echo $weblink;?></link>
<description><?php echo $description; ?></description>
<webMaster><?php echo $email_address; ?></webMaster>
<language><?php echo $lang_code; ?></language>
<lastBuildDate><?php echo date(r); ?></lastBuildDate>
<image>
  <url><?php echo $weblink . '/images/rss_logo.jpg';?></url>
  <title><?php echo $rss_title; ?></title>
  <link><?php echo $weblink;?></link>
  <description><?php echo $description; ?></description>
</image>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php

// Create SQL statement
$category = preg_replace('/[^0-9_]/', '', $_GET['cPath']);
$ecommerce = $_GET['ecommerce'];
if ($category != '') {
  // Check to see if we are in a subcategory
  if (strrpos($category, '_') > 0) {
    $category = substr($category, strrpos($category, '_') + 1, strlen($category));
  }
  $catTable = ", " . TABLE_PRODUCTS_TO_CATEGORIES . " pc ";
  $catWhere = 'p.products_id = pc.products_id AND pc.categories_id = \'' . $category . '\' AND ';
}

$sql = "SELECT p.products_id, p.products_model, p.products_date_added, pd.products_name, pd.products_description,
               m.manufacturers_name, cd.categories_name
        FROM " . TABLE_PRODUCTS . " p
             $catTable
        LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
               ON pd.products_id = p.products_id
              AND pd.language_id = '$lang_id'
        LEFT JOIN " . TABLE_MANUFACTURERS . " m
               ON m.manufacturers_id = p.manufacturers_id
        LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c
               ON p2c.products_id=p.products_id
        LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
               ON p2c.categories_id = cd.categories_id
              AND cd.language_id = '$lang_id'
        WHERE $catWhere
              p.products_status=1 AND 
              p.products_to_rss=1
        GROUP BY p.products_id
        ORDER BY p.products_id DESC
        LIMIT " . MAX_RSS_ARTICLES;

// Execute SQL query and get result
$sql_result = tep_db_query($sql) or die("Couldn't execute query: $sql");

// Format results by row
while ($row = tep_db_fetch_array($sql_result)) {
  $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'];
  $added = date(r,strtotime($row['products_date_added']));

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

  // Encoding to UTF-8
  $name = utf8_encode ($name);
  $desc = utf8_encode ($desc);
  $link = utf8_encode ($link);

  $manufacturer = $row['manufacturers_name'];
  $manufacturer = utf8_encode ($manufacturer);
  
  $cat_name = $row['categories_name'];

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

  // 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";
  echo $desc;
  echo '</description>' . "\n";
  echo '  <guid>' . $link . '</guid>' . "\n";
  echo '  <pubDate>' . $added . '</pubDate>' . "\n";
  if($ecommerce!='') {
    echo '  <ecommerce:SKU>' . $id . '</ecommerce:SKU>' . "\n";
    echo '  <ecommerce:manufacturer>' . $manufacturer . '</ecommerce:manufacturer>' . "\n";
  }
  echo '</item>' . "\n";
}
// Free resources and close connection
tep_db_free_result($sql_result);
tep_db_close();
?>
</channel>
</rss>
loris_ripa
membro Veteran
membro Veteran
Messaggi: 937
Iscritto il: 21/03/2004, 1:00
Località: Italia
Contatta:

Messaggio da loris_ripa »

Spiderweb ha scritto:Ho scoperto che con I.E. versione 7 funziona tutto bene, il problema me lo dava con la 6, però mi piacerebbe capire come si può risolvere ugualmente la cosa visto che ci sono in giro sempre molti utenti che non hanno aggiornato il browser all'ultima versione.

Sul forum ufficiale di Oscommerce (http://forums.oscommerce.com/index.php? ... 45&hl=feed) ho trovato la discussione che parla di questa contribution e fa riferimento anche a questo problema, però non c'ho capito molto... qualcuno dice di fare un mix tra la nuova e la vecchia versione e dovrebbe funzionare, mah?

Per adesso io la installo così, se poi riesco a capirci qualcosa o arriva qualcuno più esperto di me in materia è meglio :wink:
Stesso problema...
Non ho trovato però nulla sul forum ufficiale, nel thread che hai linkato parlano solo di IE7...
:D
Avatar utente
Spiderweb
membro Veteran
membro Veteran
Messaggi: 573
Iscritto il: 28/09/2005, 22:09
Località: Toscana

Messaggio da Spiderweb »

Io mi sono arreso e ho lasciato tutto così sperando (sbagliando lo sò...) che la maggior parte di utenti abbiamo IE aggiornato.

Confermo ancora che con Firefox va alla grande, un motivo in più per usarlo come browser predefinito :)
Prima di postare leggetevi le FAQ: viewtopic.php?t=3259
loris_ripa
membro Veteran
membro Veteran
Messaggi: 937
Iscritto il: 21/03/2004, 1:00
Località: Italia
Contatta:

Messaggio da loris_ripa »

Spiderweb ha scritto:Io mi sono arreso e ho lasciato tutto così sperando (sbagliando lo sò...) che la maggior parte di utenti abbiamo IE aggiornato.

Confermo ancora che con Firefox va alla grande, un motivo in più per usarlo come browser predefinito :)
Bisogna arrendersi per forza: IE6 non supporta i feed RSS, cosa che invece fa dalla 7.
Ad ogni modo le statistiche del mio sito dicono:

Msie 80.2 %

di cui:

Msie 7.0 42.2 %
Msie 6.0 36.6 %
Msie 5.5 0.3 %

Buona parte di quel 36.6% che non ha ancora aggiornato alla 7 molto probabilmente ignora cosa siano i feed RSS.
A mio pare è trascurabile il fatto che non li leggano.
:lol: :lol: :lol:
Avatar utente
Spiderweb
membro Veteran
membro Veteran
Messaggi: 573
Iscritto il: 28/09/2005, 22:09
Località: Toscana

Messaggio da Spiderweb »

Le mie statistiche per l'anno 2007 come peso relativo dicono questo:

Msie 71,80% di cui

Msie 7.0 : 26%
Msie 6.0 : 45,1%
Msie 5.5 : 0,3%
Msie 5.01: 0,1%

Invece per gennaio tra la versione 7.0 e 6.0 siamo quasi pari.
Prima di postare leggetevi le FAQ: viewtopic.php?t=3259
Rispondi