X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Syndicate X-Cart news as RSS 2.0 Channel (https://forum.x-cart.com/showthread.php?t=19661)

Acquamarina 11-23-2007 07:16 AM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Hi,

We found out the problem is actually related to the server. We are unable to rewrite files created by x-cart or any php as the mod_security blocks the access.

We might be looking for a new host and I'll post the developments. We just moved to LiquidWeb shared servers and although they are excellent (really) the shared servers are not really compatible with all of the x-cart features.

Thank you very much, I'll change the formatting on the feed for future use.

Acquamarina 11-29-2007 03:02 PM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Hi,

It is working now but there are 2 feeds, one for the news and one for newest products. Is there anyway to create a drop down list so visitors can choose which feed they would like to subscribe to?

Thank you all very much for the help!

clik 02-26-2008 06:37 PM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Quote:

Originally Posted by zaa
TheAs for the RSS extension, if you are hosted on a server with Apache web server you may add a rewrite rule that will transparently rewrite feed.xml with feed.php
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Thank you!
I appreciate your help. I'm not a specialist and I was able to follow your instructions and I did it!
but... the Auto-refresh thing... I got stuck. If you would be so nice and if you have time, could you please write the rewrite rules lines?
Thank you!

clik 03-05-2008 06:51 PM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
zaa, many thanks for your code!!!

it works and the page refreshes fine:
http://clikinternational.com/store/news_feed.php

I noticed on some website RSS subscribers counter. Is it possible to implement with your code?

zaa 03-06-2008 10:07 PM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Quote:

Originally Posted by clik
zaa, many thanks for your code!!!

it works and the page refreshes fine:
http://clikinternational.com/store/news_feed.php

I noticed on some website RSS subscribers counter. Is it possible to implement with your code?


As far as I know such counter is provided by FeedBurner.
http://www.feedburner.com/fb/a/home

Yulia 05-11-2008 08:05 AM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
I did as it was written. I have rss icon, but there is nothing in the feed (as for Pilnik and alinush). I added two products, but I don't see them in my frontpage (News and bestsellers).
What should I do:
1) to see my products on the first page (in News and bestsellers);
2) to see them in my rss feed.
Thank you.

justy 07-16-2008 04:45 PM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
I too am getting a blank feed, even though I followed all instructions re: the new version.

Have there been any updates?

zaa 07-17-2008 02:12 AM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Here is the latest version of the script (tested with X-Cart 4.1.10).

PHP Code:

<?php
/*
 * news_feed.php.
 * 2008-07-17. Zhuravlev Alexander (zaa@qualiteam.biz).
 * License: MIT (http://www.opensource.org/licenses/mit-license.php)
 * 
 * Syndicate X-Cart news as RSS 2.0 Channel
 * Script supports HTTP conditional GET
 * http://fishbowl.pastiche.org/2002/10/21/http_conditional_get_for_rss_hackers
 * 
 * Note: News should be added at News Management page of x-cart
 * administration area. Corresponding news list and messages in it should have option "Show as news" being enabled.
 * 
 */

@include_once "./top.inc.php";
if (!
defined('DIR_CUSTOMER')) die("ERROR: Can not initiate application! Please check configuration.");

define('XCART_SESSION_START'1); # We do not need any sessions
if (@file_exists($xcart_dir."/init.php")) {
    require 
$xcart_dir."/init.php";
} else {
    require 
$xcart_dir."/config.php";
}

# *Required* RSS channel properties. [[[
$rss_channel = array();

# The name of the channel. It's how people refer to your service.
$rss_channel['title'] = $config['Company']['company_name'] . " News Headlines";

# The URL to the HTML website corresponding to the channel.
$rss_channel['link'] = $http_location;

# Phrase or sentence describing the channel
$rss_channel['description'] = "The latest news from " $config['Company']['company_name'];
    
# The language the channel is written in. 
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
$rss_channel['language'] = "en";
    
# By default we assume that text is provided in UTF-8 enconding.
# You may change this according to your needs. 
$rss_channel['encoding'] = 'UTF-8';
# ]]]

define('RSS20_DATE_FORMAT',  "D, d M Y H:i:s O");
   
# Fetch messages info 
if ($active_modules['News_Management']) {
    
$messages_info func_query_first("SELECT COUNT(*) as msg_count, MAX(date) AS last_date FROM $sql_tbl[newslists] AS nl LEFT JOIN $sql_tbl[newsletter] AS n ON n.listid = nl.listid WHERE nl.avail='Y' AND nl.show_as_news='Y' AND n.show_as_news = 'Y' ORDER BY n.date DESC");
}

if (!empty(
$messages_info) && $messages_info['last_date']) {
    
$last_mod_time date(RSS20_DATE_FORMAT$messages_info['last_date']);
    
$news_page_url $http_location.DIR_CUSTOMER."/news.php";
    
$messages func_query("SELECT n.newsid, n.subject, n.body, n.date FROM $sql_tbl[newslists] AS nl LEFT JOIN $sql_tbl[newsletter] AS n ON n.listid = nl.listid WHERE nl.avail='Y' AND nl.show_as_news='Y' and n.show_as_news = 'Y' ORDER BY n.date DESC");
    
$items_code "";
    foreach (
$messages as $m) {
            
$pubDate date(RSS20_DATE_FORMAT$m['date']);
            
$m['title'] = htmlspecialchars($m['subject']);
            
$items_code .= <<<EX
        <item> 
            <title>
{$m['subject']}</title>
            <description><![CDATA[
{$m['body']}]]></description>
            <link>
$news_page_url</link>
            <guid isPermaLink="false">
{$m['newsid']}@$news_page_url</guid>
            <pubDate>
$pubDate</pubDate>
        </item>

EX;
    }
} else {
    
$last_mod_time date(RSS20_DATE_FORMATtime());
}

# Channel header
$rss_channel['title'] = htmlspecialchars($rss_channel['title']);
$rss_channel['description'] = htmlspecialchars($rss_channel['description']);
$channel = <<<EX
<?xml version="1.0" encoding="{$rss_channel['encoding']}"?>
<rss version="2.0">
    <channel>
        <title>
{$rss_channel['title']}</title>
        <link>
{$rss_channel['link']}</link>
        <description>
{$rss_channel['description']}</description>
        <language>
{$rss_channel['language']}</language>
        <generator>X-Cart</generator>
        <pubDate>
$last_mod_time</pubDate>
        <lastBuildDate>
$last_mod_time</lastBuildDate>

EX;

if (!empty(
$items_code)) {
        
$channel .= $items_code;
        unset(
$items_code);
}

$channel .= <<<EX
    </channel>
</rss>

EX;

$channel_etag '"'.md5($channel).'"';

# Conditional GET logic [[[
# Check if the channel contents should be passed to client.
# We analyze HTTP response headers: If-Modified-Since, If-None-Match

$IMS_FLAG 0;
if (!empty(
$HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE'])) {
        if (
strtotime($HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE'])  == strtotime($last_mod_time)) {
              
$IMS_FLAG 1;
        }
}

$INM_FLAG 0;
if (!empty(
$HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH'])) {
        if (
$HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH']  == $channel_etag) {
              
$INM_FLAG 1;
        }
}

$pass_channel_to_client = !($IMS_FLAG || $INM_FLAG);
# ]]]

if (!$pass_channel_to_client) {
    
header("HTTP/1.0 304 Not Modified");
    
header('ETag: ' $channel_etag);
} else {
    
# Output headers [[[
    
header("Content-Type: application/xml; charset=".$rss_channel['encoding']);
    
header("Content-length: " strlen($channel));
    
header("Last-Modified: " $last_mod_time);
    
header('ETag: ' $channel_etag);
    
# ]]]

    
echo $channel;
}

# vim600: set et sw=4 sts=4 ts=4 fdm=marker fmr=[[[,]]]:
?>



Note: The script is intended for displaying of news. If you would like to create a feed with the latest store products, etc then you need to adjust it according to your needs.

Best regards,

justy 07-17-2008 07:05 AM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Thanks, zaa. I've uploaded the new version, but it still doesn't work. I'm still using x-cart 4.1.9, though, so maybe it's my using the old version?

zaa 07-17-2008 08:52 AM

Re: Syndicate X-Cart news as RSS 2.0 Channel
 
Quote:

Originally Posted by justy
Thanks, zaa. I've uploaded the new version, but it still doesn't work. I'm still using x-cart 4.1.9, though, so maybe it's my using the old version?


Do you see any errors?
First of all, make sure that your created a news list (with Show messages in site news option being enabled) and added a message (with show as news option being enabled).

Generally, if you added some news entries and you can successfully see them at http://www.example.com/news.php, you should be able to see them in a RSS feed generated with help of the http://www.example.com/news_feed.php file.


All times are GMT -8. The time now is 07:46 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.