Show RSS feed using PHP on X-Cart Homepage using Simple Pie

Here is a tutorial on how to show an RSS feed on your X-Cart Homepage without javascript. This allows google to see that your homepage is showing updated content regularly.

1. firstly you will need to download the latest version of SimplePie from the simple pie website. http://simplepie.org/downloads/

2. In your X-Cart directory create a folder called ‘simplepie’ inside the modules folder. ie, /modules/simplepie

3. Upload simplepie.inc and LICENSE.txt from the simplepie archive to /modules/simplepie

4. Create a folder called cache inside /modules/simplepie and give this file 755 or 777 file permissions.

5. Edit the file /modules/simplepie/simplepie.inc and find

1
2
3
4
5
6
/**
* @var string Cache location (relative to executing script)
* @see SimplePie::set_cache_location()
* @access private
*/

var $cache_location = './cache';

change this to

1
2
3
4
5
6
/**
* @var string Cache location (relative to executing script)
* @see SimplePie::set_cache_location()
* @access private
*/

var $cache_location = './modules/simplepie/cache';

6. Now create a new folder called rss in the modules folder ie, /modules/rss

7. Create a file called rss.php and enter the following information.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
if (!defined('XCART_SESSION_START')) { header("Location: ../../"); die("Access denied"); }

include_once($xcart_dir . '/modules/simplepie/simplepie.inc');

$feed = new SimplePie();
 
$feed->set_feed_url("http://www.zone1creative.co.uk/blog/feed");
$feed->enable_cache(true);
$feed->init();

$i = 0;
foreach ($feed->get_items() as $item) {
  $rssitem['title'] = $item->get_title();
  $rssitem['url'] = $item->get_permalink();
$rssitem['description'] = = $item->get_description();
  $rss[] = $rssitem;
 
//set value to how many feed items to show
  if(++$i > 4) break;
}

$smarty->assign_by_ref('rss', $rss);
?>

Change the line http://www.zone1creative.co.uk/blog/feed to your rss url.

Upload this file to /modules/rss

8. Download and edit /home.php
Find

1
2
3
if (!empty($active_modules['Gift_Registry'])) {
    include $xcart_dir . '/modules/Gift_Registry/customer_events.php';
}

and add below it

1
2
3
4
5
6
7
if (!empty($active_modules['Gift_Registry'])) {
    include $xcart_dir . '/modules/Gift_Registry/customer_events.php';
}

if ($cat == 0) {
  include $xcart_dir . '/modules/rss/rss.php';
}

Upload the file again.

9. We now need to edit the smarty template file /skin/{your skin folder}/customer/main/welcome.tpl

1
2
3
4
5
6
7
8
9
10
11
12
13
{if $rss}
  <ul id="rss-block">
  {foreach from=$rss item=rssitem}
    {if $rssitem.title != ""}
    <li>{if $rssitem.url != ""}<a href="{$rssitem.url}" target="blog">{/if}{$rssitem.title}{if $rssitem.url != ""}</a>{/if}
    <div class="description">
    {$rssitem.description}
    </div>
    </li>
    {/if}
  {/foreach}
  </ul>
{/if}

One thought on “Show RSS feed using PHP on X-Cart Homepage using Simple Pie

  1. Pingback: New site redesign for Leather Jackets store by Zone1Creative | SEO marketing Brighton

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>