Here's Boomer's RSS mod updated to work with 4.0.12 -4.0.16.
Should work with all 4.0 versions, but I haven't tested below 4.0.12.
Note!
The installation is a bit different than the 3.0xx version. (more of a option really)
Also, just to keep things simple & avoid some bald spots, you might
not want to change any of the code/feed URLs, until AFTER you've uploaded/ tested the mod & know it works.
Step 1:
Log into your admin & go to "Languages" and create a lbl_rssfeed. This is
what will show in the crumb trail. ie: "Home :: Live News"
Step 2:
Create a rss.php file with the code below & upload to /xcart/rss.php.
rss.php
Code:
<?php
/*
X-Cart RSS Parser
Original code adopted by Christian Jц╦rgensen (http://www.razor.dk)
Modified for X-Cart by Jared Blalock (http://www.cart-lab.com)
*/
# require X-Cart functions
require "./auth.php";
require $xcart_dir."/include/categories.php";
if ($active_modules["Manufacturers"])
include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";
# Edit these URLS of RSS/XML feeds you'd like to have on your site
# RSS Feed Urls
$backends = array("http://www.ecommercetimes.com/perl/syndication/rssfull.pl",
"http://www.wired.com/news/feeds/rss2/0,2610,10,00.xml",
"http://headlines.internet.com/internetnews/ec-news/news.rss",
"http://www.sitepoint.com/recent.rdf",
"http://p.moreover.com/cgi-local/page?c=E%2Dcommerce%20news&o=rss",
"http://p.moreover.com/cgi-local/page?c=Online%20marketing%20news&o=rss",
"http://p.moreover.com/cgi-local/page?c=Web%20developer%20news&o=rss");
# RSS Feed Names
$backend_names = array("E-Commerce Times",
"Wired News: E-Biz",
"E-Commerce News (internet.com)",
"SitePoint.com Recent Articles",
"E-Commerce News (moreover.com)",
"Online Marketing (moreover.com)",
"Web Developer News (moreover.com)");
# Set default if none selected
if(!$backend) $backend = $backends[0];
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# NO NEED TO EDIT BELOW
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Some vars used later on
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $tagName, $attrs) {
// The function used when an element is encountered
global $insideitem, $tag;
if ($insideitem) {
$tag = $tagName;
} elseif ($tagName == "ITEM") {
$insideitem = true;
}
}
function characterData($parser, $data) {
// The function used to parse all other data than tags
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
function endElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link, $feed;
if ($tagName == "ITEM") {
# modified by cart-lab.com
$feed .= "
<li type='disc'>".htmlspecialchars(trim($title))."
";
$feed .= trim($description)."
";
$title = $description = $link = $insideitem = false;
# modified by cart-lab.com
}
}
// Now to the parsing itself. Starts by creating it:
$xml_parser = xml_parser_create();
// Then setup the handlers:
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
// Open the actual datafile:
$fp = fopen($backend, r);
// Run through it line by line and parse:
while ($data = fread($fp, 4096)) {
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
// Close the datafile
fclose($fp);
// Free any memmory used
xml_parser_free($xml_parser);
# modified by cart-lab.com add to by rdcenterprises.com so blame me if it doesn't work! ;-)
$smarty->assign("main","rss");
$smarty->assign("feeds",$feed);
$smarty->assign("backend",$backend);
$smarty->assign("backends",$backends);
$smarty->assign("backend_names",$backend_names);
$location[] = array(func_get_langvar_by_name("lbl_rssfeed"));
$smarty->assign("location", $location);
func_display("customer/home.tpl",$smarty);
?>
Step 3:
Create the "rss.tpl" from the code below & upload to:
/xcart/skin1/customer/main/rss.tpl
rss.tpl
Code:
{capture name=dialog}
<form name="feeds" method=post action="">
<select name="backend" onChange="document.feeds.submit();">
{$backend}
{section name=oi loop=$backends}
<option value="{$backends[oi]}" {if $backend eq $backends[oi]}selected{/if}>{$backend_names[oi]}</option>
{/section}
</select>
</form>
{$feeds}
{/capture}
{include file="dialog.tpl" title="E-Commerce News" content=$smarty.capture.dialog extra="width=100%"}
Step 4: (you can do this part in skin1/common_templates.tpl or /skin1/customer/home_main.tpl) I prefer the later, cause home_main.tpl
is called before common_templates.tpl.
K! Add the following code to the bottom of "/skin1/customer/home_main.tpl"
just
BEFORE the
"{else}
{include file="common_templates.tpl"}
{/if}"
home_main.tpl
Code:
{elseif $main eq "rss"}
{include file="customer/main/rss.tpl"}
So the bottom will look like so:
Code:
{elseif $main eq "rss"}
{include file="customer/main/rss.tpl"}
{else}
{include file="common_templates.tpl"}
{/if}
Step 5: Put a link on your home page.
I put mine at the bottom of the "/skin1/news.tpl"
ie:
News from around the World
Now, call the rss.php with your browser. If it loads...ya be DONE!
