Use Magento getUrl inside function

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']; } 

I want to know if I can use the Mage :: getUrl ('/ whatever') function inside this function. In particular, I need to use the link inside

  else { $this->_data['welcome'] = $this->__('Welcome, <a href="">Sign in</a> or <a href="">Register</a>'); } 

Thanks.

EDIT Solution:

 $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') 

);

+4
source share
1 answer

The __() function works like sprintf() . You can use directives such as:

 $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') ) 

The pure part of this is directives that can be used in any order, you can translate above:

 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>. 
+7
source

All Articles