网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > X-Cart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 112.84.243.88
Old 2015-03-31, 04:37 PM
Kachina Village Kachina Village is offline
初级会员
 
Join Date: 2010-05-30
Posts: 2
Kachina Village 现在声名狼藉
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
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);

?>
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"}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Steps to Change Your Table Prefix in WordPress Abby WordPress 0 2014-04-14 03:40 PM
How to Split Long WordPress Posts into Multiple Pages topvip WordPress 0 2013-05-04 07:24 PM
Install WordPress on IIS topvip Blog(博客)/Wiki(维客)/RSS/Cms 1 2010-01-25 08:31 PM
wordpress 搜索引擎优化的二十条实用技巧 car 搜索引擎优化 0 2008-03-11 08:33 AM
Latest X Posts on Forum Home yahoo vBulletin技术交流 0 2007-12-02 07:14 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:51 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.