CubeCart and Wordpress Integration
November 1st, 2007Following my 100% CubeCart orientated posts, here’s another late night hack.
It integrates a Wordpress blog into your store’s homepage.
You need a working Wordpress installation to start with, I installed mine in the standard /wordpress/ folder, none of your customers will see it anyway.
You will also need SimplePie which is a very fast and simple RSS Parser for PHP. Just download and place in any directory.
First off, edit includes/content/index.inc.php and put this about line 55
require('LOCATION TO SIMPLE PIE/simplepie.inc');$feed = new SimplePie('LOCATION TO WORDPRESS FEED'); $feed->handle_content_type();$i = 1; $posts = Array(); foreach ($feed->get_items() as $item) { $posts[$i]['LINK'] = $item->get_permalink(); $posts[$i]['TITLE'] = $item->get_title(); $posts[$i]['CONTENT'] = $item->get_content(); $posts[$i]['DATE'] = $item->get_date('j F Y | g:i a'); // assign array data $index->assign('DATA', $posts[$i]); $index->assign('ROW_NR', $i); // parse a row $index->parse('index.table.row'); $i++; } $index->parse('index.table');
Make sure you replace “LOCATION TO SIMPLE PIE” with the correct page.
Make sure you replace “LOCATION TO WORDPRESS FEED” with your wordpress feed. Don’t know what this is? Goto your Wordpress blog and hit the RSS icon in the location bar to go to the feed location.
Next, edit yourskin/styleTemplates/content/index.tpl. I replaced the following
<!-- BEGIN: welcome_note --> <p id="Announcement"><!--start Announcement--> <p class="Title"> <h1>{HOME_TITLE}</h1> {HOME_CONTENT} <!--close Announcement --> <!-- END: welcome_note -->
with
<!-- BEGIN: table --> <!-- BEGIN: row --> <p class="Title"> <h1><a href="{DATA.LINK}">{DATA.TITLE}</a></h1> {DATA.CONTENT} {DATA.DATE} <!-- END: row --> <!-- END: table -->
This will replace the “Home Page” text with your blog entries.
Simple, huh?
If any one needs any help, customisation etc, contact me.
| Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo |
Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the CubeCart, Geekery, PHP category.
July 25th, 2008 at 07:37
i have been trying to your wordpress integration but i get this error:
Parse error: syntax error, unexpected ‘&’ in /home/ourspot/public_html/includes/content/index.inc.php on line 60
s
July 25th, 2008 at 08:11
ok so i sorted that bit out by replacing > with > but unfortunatley now i get this in the space where the blog should be
[XTemplate]
* parse: blockname [index.welcome_note] does not exist
* parse: blockname [index.table] does not exist
* parse: blockname [index] does not exist
October 1st, 2008 at 16:56
[...] Previous blog entry on Estelles’s Mod Store. [...]