public function getWelcome()
{
if (empty($this->_data['welcome'])) {
if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
} else {
$this->_data['welcome'] = $this->__('Welcome, <a href="">Sign in</a> or <a href="">Register</a>');
}
}
return $this->_data['welcome'];
}
Run Code Online (Sandbox Code Playgroud)
我想知道我是否可以在这个函数中使用函数Mage :: getUrl('/ whatever').更具体地说,我需要在里面使用一个链接
else {
$this->_data['welcome'] = $this->__('Welcome, <a href="">Sign in</a> or <a href="">Register</a>');
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
编辑 解决方案:
$this->__('Welcome, <a href="%1$s">Sign in</a> or <a href="%2$s">Register</a>',
Mage::getUrl('customer/account/login'),
Mage::getUrl('customer/account/create')
Run Code Online (Sandbox Code Playgroud)
);
该__()功能的工作原理类似sprintf().你可以使用这样的指令:
$this->__('Welcome, <a href="%1$s">Sign in</a> or <a href="%2$s">Register</a>',
Mage::getUrl('customer/account/login'),
Mage::getUrl('customer/account/create')
)
Run Code Online (Sandbox Code Playgroud)
这个整洁的部分是指令可以按任何顺序使用,你可以将上面的内容翻译成:
Please <a href="%2$s">sign-up</a> or, if you have an existing account,
<a href="%1$s">login</a>. To justify this example here is the register URL again;
<q>%2$s</q>.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5419 次 |
| 最近记录: |