Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Display latest Wordpress Posts

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 06-08-2009, 02:44 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Display latest Wordpress Posts

This mod assumes that you use the Wordpress blogging software and uses the same database as your xcart software.
If your wordpress and x-cart use separate database then use this code for blog_headlines.php

If you do not use the default Wordpress SQL table prefix than you will need to specify it in the select query.
For example, change wp_posts to yourprefix_posts

Create xcart-root/include/blog_headlines.php and paste this in it:
Code:
<?php $blog_headlines = func_query("SELECT post_title,guid,post_date as orderby, DATE_FORMAT(post_date,'%d/%m/%Y') as post_date FROM wp_posts WHERE post_status = 'publish' group by post_title order by orderby desc limit 3"); array("blog_headlines" => array()); $smarty->assign("blog_headlines", $blog_headlines); ?>

Create xcart-root/skin1/blog_headlines.tpl and paste this in it:
Code:
{* $Id: blog_headlines.tpl,v1 09/01/29 11:18:59 max Exp $ *} {capture name=menu} {foreach from=$blog_headlines item=bh}<a href="{$bh.guid}" class="blog_headlines">{$bh.post_title}</a><div class="blog_headlines">{$bh.post_date}</div><br class="blog_headlines"/><hr noshade="noshade" size="1" class="blog_headlines" />{/foreach} {/capture} {include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title="Blog Headlines" menu_content=$smarty.capture.menu}

Open xcart-root/init.php and add this at the end:
Code:
#Blog Headlines include($xcart_dir."/include/blog_headlines.php");

Open xcart-root/skin1/skin1.css and add this:
Code:
/*** Blog Headlines Styles Start ***/ a.blog_headlines { /* The link */ display:block; } a.blog_headlines:hover { /* The link when hovered over */ background:#d7d7d7; } hr.blog_headlines { /* The line */ color:#e1e1e1; } div.blog_headlines { /* The date */ float:right; } br.blog_headlines{ clear:left; } /*** Blog Headlines Styles End ***/

Open xcart-root/skin1/customer/home.tpl file and add this within VertMenuLeftColumn (or where ever appropriate):
Code:
{include file="blog_headlines.tpl"}
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #2  
Old 06-13-2009, 01:23 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Default Re: Display latest Wordpress Posts

hi autobulbs,
This seems nice mod.
can you please tell me what I need to do if I am using different database for my x-cart & wordpress ?

Thanks.
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #3  
Old 06-16-2009, 10:37 PM
  crazyoval's Avatar 
crazyoval crazyoval is offline
 

X-Adept
  
Join Date: Jun 2006
Location: UK
Posts: 559
 

Default Re: Display latest Wordpress Posts

HI autobulbs, nice one! what a great idea, bring x-cart sites up a sep.

just a tad too complicated for me to play with a live site. Do you have a live site running it today that I can see it working?
__________________
X-Cart 4.1.11 on Linux
HandsOnWebHosting: Very helpful & professional
Custom Skin Design by ARS.
Numerous, ney, hundreds of modifications by ARS.
AlteredCart: Download Expander, One Page Checkout,
BCS Engineering: Great team, Top service.
WebsiteCM: good products & very professional
CDSEO, Hidden Categories, Custom Work
Magnetic One Store Manager: Brill
Forms To Go: Excellent+A+support
Reply With Quote
  #4  
Old 06-17-2009, 12:28 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Display latest Wordpress Posts

Hi crazyoval

Yes we have it running on http://www.bhpplus.co.uk/ (On the left, as Diesel News) Which is using the code in the original post.

And also on http://www.autobulbsdirect.co.uk/ (Under Latest Automotive News) But this is a heavily modified wordpress so the code is slightly different, but the principle is the same.

----------------------------------------------
anandat, I will look into that later this week
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #5  
Old 09-26-2009, 02:34 PM
 
canuck canuck is offline
 

Advanced Member
  
Join Date: Oct 2007
Location: Ontario, Canada
Posts: 65
 

Default Re: Display latest Wordpress Posts

Quote:
Originally Posted by anandat
hi autobulbs,
This seems nice mod.
can you please tell me what I need to do if I am using different database for my x-cart & wordpress ?

Thanks.

I just ran across this post and I'm looking to do the same -- add most recent wordpress posts on my main x-cart home page. But my wordpress database is separate. Does anyone know how to do it?

I've seen rss mods but this seems like a cleaner way, no? Or does the separate database complicate things too much?
__________________
X-Cart Gold 4.1.10
AARtech Canada
Reply With Quote
  #6  
Old 09-28-2009, 03:52 AM
 
autobulbs autobulbs is offline
 

Advanced Member
  
Join Date: Feb 2007
Location: Southampton, UK
Posts: 68
 

Default Re: Display latest Wordpress Posts

I did solve this, and here is how:

PHP Code:
<?php

#Connect to the wordpress database
db_connect('wp db host''wp db user''wp db pass');
db_select_db('wp db name');

#Select the posts
$blog_headlines func_query("SELECT post_title,guid,post_name,ID,DATE_FORMAT(post_date,'%d/%m/%Y') as post_date, post_date as orderbythis FROM wp_posts WHERE post_status = 'publish' GROUP BY post_title ORDER BY orderbythis DESC LIMIT 3;");

#Stuff them into a smarty array
array("blog_headlines" => array());
$smarty->assign("blog_headlines"$blog_headlines);

#Connect to the X-Cart database - these variables are in config.php
db_connect($sql_host$sql_user$sql_password);
db_select_db($sql_db);

?>
__________________
Autobulbs Direct Ltd
X-Cart Version: 4.2.2
eWay Designs - Custom X-Cart Templates / CMS Websites / Bespoke web applications
Reply With Quote
  #7  
Old 10-10-2009, 05:17 PM
 
Scott DeToffol Scott DeToffol is offline
 

Senior Member
  
Join Date: Apr 2005
Location: Minneapolis, MN
Posts: 174
 

Default Re: Display latest Wordpress Posts

I'm pulling in posts to X-cart sidebar using RSS via javascript from http://www.rssinclude.com/.

But I'm looking for a PHP solution. I think http://simplepie.org/ should be able to do it, but haven't dug in to figure it out yet.
__________________
Scott DeToffol
Online Marketing and E-Commerce Consulting in Minneapolis

X-Cart Gold Version 4.1.9 for www.sundogtrading.com
X-Cart Pro Version 4.2.3 for www.heavyglare.com
Reply With Quote

The following user thanks Scott DeToffol for this useful post:
anandat (10-10-2009)
  #8  
Old 10-10-2009, 10:51 PM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 914
 

Thumbs up Re: Display latest Wordpress Posts

Quote:
Originally Posted by Scott DeToffol
I'm pulling in posts to X-cart sidebar using RSS via javascript from http://www.rssinclude.com/.

But I'm looking for a PHP solution. I think http://simplepie.org/ should be able to do it, but haven't dug in to figure it out yet.

Thanks Scott DeToffol
rssinclude.com looks good as it's support twitter also. will try to play with this in next weekend.
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #9  
Old 12-29-2010, 09:51 PM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Display latest Wordpress Posts

Quote:
Originally Posted by autobulbs
This mod assumes that you use the Wordpress blogging software and uses the same database as your xcart software.
If your wordpress and x-cart use separate database then use this code for blog_headlines.php

If you do not use the default Wordpress SQL table prefix than you will need to specify it in the select query.
For example, change wp_posts to yourprefix_posts

Create xcart-root/include/blog_headlines.php and paste this in it:
Code:
<?php $blog_headlines = func_query("SELECT post_title,guid,post_date as orderby, DATE_FORMAT(post_date,'%d/%m/%Y') as post_date FROM wp_posts WHERE post_status = 'publish' group by post_title order by orderby desc limit 3"); array("blog_headlines" => array()); $smarty->assign("blog_headlines", $blog_headlines); ?>

Create xcart-root/skin1/blog_headlines.tpl and paste this in it:
Code:
{* $Id: blog_headlines.tpl,v1 09/01/29 11:18:59 max Exp $ *} {capture name=menu} {foreach from=$blog_headlines item=bh}<a href="{$bh.guid}" class="blog_headlines">{$bh.post_title}</a><div class="blog_headlines">{$bh.post_date}</div><br class="blog_headlines"/><hr noshade="noshade" size="1" class="blog_headlines" />{/foreach} {/capture} {include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title="Blog Headlines" menu_content=$smarty.capture.menu}

Open xcart-root/init.php and add this at the end:
Code:
#Blog Headlines include($xcart_dir."/include/blog_headlines.php");

Open xcart-root/skin1/skin1.css and add this:
Code:
/*** Blog Headlines Styles Start ***/ a.blog_headlines { /* The link */ display:block; } a.blog_headlines:hover { /* The link when hovered over */ background:#d7d7d7; } hr.blog_headlines { /* The line */ color:#e1e1e1; } div.blog_headlines { /* The date */ float:right; } br.blog_headlines{ clear:left; } /*** Blog Headlines Styles End ***/

Open xcart-root/skin1/customer/home.tpl file and add this within VertMenuLeftColumn (or where ever appropriate):
Code:
{include file="blog_headlines.tpl"}

Hi I have x cart Pro 4.1.9 and my wordpress is in my same folder(within blog folder) of my domain with different database.After Adding codes
-#Blog Headlines
include($xcart_dir."/include/blog_headlines.php"); at the end
The entire store getting blank.How to solve this issue??

What is the exact codes for 4.1.9 Versions??

How to resolve this issue??
__________________
4.6.1 Platinum


Reply With Quote
  #10  
Old 01-18-2011, 09:52 PM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Re: Display latest Wordpress Posts

Hi,
Will it compatible with 4.4 version??
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:59 PM.

   

 
X-Cart forums © 2001-2020