添加站点链接到magento模板文件


add site links to magento template files

添加链接到Magento模板文件的最佳方法是什么?

目前我正在使用下面的方法,但我想知道是否有一个更好的方法调用本地magento方法?

<a href="about-us"><?php echo $this->__('About Us'); ?></a>
<a href="checkout/cart">?php echo $this->__('Shopping Bag'); ?></a>

我知道你可以使用<img src="<?php echo $this->getSkinUrl('images/test.png');?>" />来获取图像url,是否有类似的链接?

使用以下代码在模板文件

中获取URL
 $this->getUrl('module/controller/action'); //for controller pages 
 $this->getUrl('', array('_direct'=>'some-url-key')); //for cms pages 
 $this->getUrl('module/controller/action', array('_query'=>'a=2&b=5')); //for query params 
 $this->getUrl('', array('_direct'=>'some-url-key', '_query'=>'a=2&b=5')); //for query params

参考此链接https://magento.stackexchange.com/questions/14443/magento-get-store-url-in-cms-page

你可以把链接放在静态块上,然后在模板文件中调用该静态块。

在静态块代码中

将是

<ul>
<li><a href="{{store direct_url="about-us"}}">About Us</a></li>
<li><a href="{{store direct_url="customer-service"}}">Customer Service</a></li>
</ul>