在Magento中显示wordpress的文章
1、在magento根目录下安装wordpress
把wordpress安装包源码上传到你的magento根目录,用址:http://yourdomain.com/magento/wordpress来 安装,这里的安装路径按你的实际情况来定,如果你的magento直接安装在网站根目录,那么就用http://yourdomai.com/wordpress来安装,注意安装的时候你可以装在magento的数据库中,最好把你wordpress的表加个前缀防止和magento的表有 冲突,当然你也可以把wordpress安装在独立的数据库。或者你可以现在本地开发好wordpress,然后把它迁移到你的服务器上,可以参考文章WordPress迁移服务器最简单的办法。
2、调用wordpress中的文章
安装好后接下来我们就要想办法把wordpress的文章调用到magento页面中,在这里我们利用的wordpress的RSS输出。
在你当前使用的magento模板中新建一个blog.phtml,比如app/design/frontend/default/default/template/callouts/blog.phtml文件,然后在里面加入下列代码:
<?php $channel = new Zend_Feed_Rss(’http://yourdomin/blog/?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><a href=”<?php echo $item->link; ?>”><?php echo $item->title; ?></a></li> <?php endforeach; ?> </ol> </div> </div> </pre> <pre>
3、现在我们就要在magento布局中调用这个blog.phtml文件
a)如果只想在产品页调用
打开catalog.xml文件 找到<catalog_product_view>,然后在<refrence name=”right”></refrence>中加入代码,
<block type=”core/template” template=”callouts/blog.phtml”/>
b)在CMS页面中调用
在后台CMS页面中调用代码{{block type=”core/template” template=”callouts/blog.phtml”/}}
心晴客栈 » 在Magento中显示wordpress的文章