我已经通过下面的代码将顶部链接中的文本"我的购物车"改为"我的购物袋"。
public function addCartLink()
{
$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
$count = $this->getSummaryQty() ? $this->getSummaryQty()
: $this->helper('checkout/cart')->getSummaryCount();
if ($count == 1) {
$text = $this->__('My Shopping Bag (%s)', $count);
} elseif ($count > 0) {
$text = $this->__('My Shopping Bag (%s)', $count);
} else {
$text = $this->__('My Shopping Bag');
}
$parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');
}
return $this;
}
现在,我想把标签应用到购物车数量。所以,它应该看起来像我的购物袋0。0(数量)应该用红色表示。那我该怎么办呢?
你的代码是正确的,但在其他部分它想要棘手的方式。你可以这样展示$text = $this->__('我的购物袋(0)');愿它对你有所帮助
谢谢Anand
可以直接添加<span>
public function addCartLink()
{
$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
$count = $this->getSummaryQty() ? $this->getSummaryQty()
: $this->helper('checkout/cart')->getSummaryCount();
if ($count == 1) {
$text = $this->__('My Shopping Bag <span>(%s)</span>', $count);
} elseif ($count > 0) {
$text = $this->__('My Shopping Bag <span>(%s)</span>', $count);
} else {
$text = $this->__('My Shopping Bag');
}
$parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');
}
return $this;
}