1、在magento根目錄下安裝wordpress
把wordpress安裝包源碼上傳到你的magento根目錄,用址:http://yourdomain.com/magento/wordpress來 安裝,這里的安裝路徑按你的實際情況來定,如果你的magento直接安裝在網(wǎng)站根目錄,那么就用http://yourdomai.com/wordpress來安裝,注意安裝的時候你可以裝在magento的數(shù)據(jù)庫中,最好把你wordpress的表加個前綴防止和magento的表有 沖突,當然你也可以把wordpress安裝在獨立的數(shù)據(jù)庫。或者你可以現(xiàn)在本地開發(fā)好wordpress,然后把它遷移到你的服務器上,可以參考文章Wordpress遷移服務器最簡單的辦法。
2、調(diào)用wordpress中的文章
安裝好后接下來我們就要想辦法把wordpress的文章調(diào)用到magento頁面中,在這里我們利用的wordpress的RSS輸出。
在你當前使用的magento模板中新建一個blog.phtml,比如app\design\frontend\default\default\template\callouts\blog.phtml文件,然后在里面加入下列代碼:
<?php
$channel = new Zend_Feed_Rss('http://127.0.0.1/mgt142/wordpress/?feed=rss2');
?>
<div>
<div>
<h2><?php echo $this->__("Latest Articles form the Blog"); ?></h2>
</div>
<div>
<ol id=”graybox-latest-news”>
<?php foreach ($channel as $item): ?>
<li>
<?php echo $item->link; ?>
<a href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
</li>
<?php endforeach; ?>
</ol>
</div>
</div>
3、現(xiàn)在我們就要在magento布局中調(diào)用這個blog.phtml文件
a)如果只想在產(chǎn)品頁調(diào)用
打開catalog.xml文件 找到<catalog_product_view>,然后在<refrence name=”right”></refrence>中加入代碼,
<block type=”core/template” template=”callouts/blog.phtml”/>
b)在CMS頁面中調(diào)用
在后臺CMS頁面中調(diào)用代碼{{block type=”core/template” template=”callouts/blog.phtml”/}}