Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

I wanted to put an infobox in an OsCommerce store with a random post from the store's Wordpress blog, I couldn't find a module/add on for this so created a simple one.

 

The details on it can be found - Wordpress Post as Infobox in Oscommerce

 

The working example can be found - Welly Warehouse

 

Not sure it warrants a contribution yet as it would need a little more work for all the different Wordpress URL display options but hopefully it might save someone some time.

 

Cheers,

Graeme.

 

<?php
/*
 $Id: blog.php,v 1.0 2008/04/03 22:31:00 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Created by Graeme Finlayson.
 www.econcepts.co.uk
 Donations welcome! :D

 Released under the GNU General Public License
*/
$blog_hostname_link 		= "localhost"; 		//usually "localhost"
$blog_database_link 		= "blogdatabase";	//wordpress database name
$blog_username_link 		= "bloguser";		//wordpress username
$blog_password_link 		= "blogpassword";	//wordpress password

$blog_title 				= "My Blog!";		//the title of your blog
$blog_location 			= "http://www.yourdomainname.com/blog/"; 
												//the location of your blog
$number_of_chars_to_display = 200;

?>
<!-- blog //-->
	  <tr>
		<td>
<?php
//we want one random blog post in here.
$blog_link = mysql_connect($blog_hostname_link, $blog_username_link, $blog_password_link) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($blog_database_link, $blog_link);
$blog_sql = "SELECT post_name, post_date, id, post_content, post_title FROM wp_posts ORDER BY rand() LIMIT 1;";
$blog_result = mysql_query($blog_sql, $blog_link);

$blog_row = mysql_fetch_assoc($blog_result);

tep_db_connect() or die('Unable to connect to database server!');

$info_box_contents = array();
$info_box_contents[] = array('text' => "<a style='color:#ffffff;' href='".$blog_location."'>".$blog_title."</a>");

 new infoBoxHeading($info_box_contents, true, true);

 $info_box_contents = array();
 $sef_url = $blog_location."index.php/".substr($blog_row["post_date"],0,4)."/".substr($blog_row["post_date"],5,2)."/".substr($blog_row["post_date"],8,2)."/".$blog_row["post_name"];
 $info_box_contents[] = array('text' => '<h2><b><a href="'.$sef_url.'">'.$blog_row["post_title"].'</b></a></h2>
  <span style="font-size:12px;"><br/>'.substr(strip_tags($blog_row["post_content"]),0,$number_of_chars_to_display).'...</span><br/><br/>
  <a href="'.$sef_url.'">(read more)</a></br>
 ');

 new infoBox($info_box_contents);
//display box footer
 $info_box_contents = array();
 $info_box_contents[] = array('text' => " ");

 new infoBoxFooter($info_box_contents, true, true);
?>
		</td>
	  </tr>
<!-- blog_eof //-->

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...