1、在Ecshop根目录找到index.php文件,在127行插入如下代码:$smarty->assign('new_wordpress', index_get_new_wordpress()); // wordpress插入代码后的截图:
2、再在这个index.php文件中搜索私有函数“PRIVATE FUNCTIONS”,找到下面的代码:/*-幻腾寂埒----------------------------------------------------- *///-- PRIVATE FUNCTIONS/*------------------------------------------------------ */在这段私有函数“PRIVATE FUNCTIONS”代码后添加以下代码:function index_get_new_wordpress(){ $sql = "SELECT ID, post_title, guid FROM wp_posts where post_status='publish' ORDER BY ID DESC LIMIT 0,9"; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res AS $idx => $row) { $arr[$idx]['id'] = $row['ID']; $arr[$idx]['title'] = $row['post_title']; $arr[$idx]['url'] = $row['guid']; } return $arr;}上面代码中有个数字“9”,这个数字“9”表示调用9篇最新的wordpress文章。插入代码后的截图:
3、新建一个名为“wordpress.盟敢势袂lbi”的文件,不会建?我也不会建,用笨办法,找到Ecshop根目录下\themes\您丬涪斟享正在使用的主题名称\library,在这个library的文件夹里复制一个.lbi的文件,更改成名为“wordpress.lbi”的文件,再删除这个文件里的代码。在这个新建的名为“wordpress.lbi”的文件里添加如下代码(共13行):<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div id="mallNews" class="f_r box_1"> <h3><span><a href="http://www.nadou.net/blog/" target="_blank">纳豆博客</a> 最近博文:</span></h3> <div class="NewsList tc" style="border-top:none"> <ul> <!-- {foreach from=$new_wordpress item=wordpress} --> <li> <a href="{$wordpress.url}" title="{$wordpress.title|escape:html}" target="_blank">{$wordpress.title|truncate:26}</a> </li> <!-- {/foreach} --> </ul> </div></div>植入代码后的截图:以上代码说明:3-1、个性化标题可去掉“最近博文:”<h3><span><a href="http://www.nadou.net/blog/" target="_blank">纳豆博客</a> 最近博文:</span></h3>可改为:<h3><a href="http://www.nadou.net/blog/" target="_blank">纳豆博客</a></h3>h3标签可改为h2或h4或其他h标签。3-2、标题长度控制代码“truncate:26”,“26”表示第26个字后截断。3-3、如果你打算彻底放弃ecshop的文章系统,可将“wordpress.lbi”里的代玛内容放到所在主题的lbi文件里,我的就放在主题名称/library/new_articles.lbi
4、在你所使用的主题的index.dwt文件中,插入调用“wordpress.lbi”文件的代码:<!-- #BeginLibraryItem "/library/wordpress.lbi" -->插入代码后的截图(仅供参考):每个主题不同,这行代码插入的地方也不同,上面代码插入的地方仅供网友做个参考。