1

Hi i want to customise my welcome message like this:

"hi visitor, welcome to %storename%! Log in or register."

but i don't know how i should include the login link, because if you logged in, the message will have to change like this: hi %username% you're logged in. logout?

or something else. Thank you in advance

0

2 Answers 2

2

Maurice Magento is managed manged welcome message from

Mage_Page_Block_Html_Welcome class _toHtml() function

Mage_Page_Block_Html_Header class getWelcome function

Step1:Copy app/code/core/Mage/Page/Block/Html.php

to app/code/local/Mage/Page/Block/Html.php

change code of getWelcome

if (empty($this->_data['welcome'])) {
    if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
        $this->_data['welcome'] = $this->__(' hi %s% youre loggin in. <a href="%s">logout?</a>', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()),Mage::helper('customr')->getLogoutUrl());
    } else {
        //$this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
    $this->_data['welcome'] = $this->__('hi visitor,  to %s! <a  href="%s">Log<a> in or <a href="%s">register</a>', $this->escapeHtml(Mage::app()->getStore()->getFrontendName()),Mage::helper('customer')->getLoginUrl(),Mage::helper('customer')->getRegisterUrl());

    }
}

return $this->_data['welcome'];

Step2:

Copy app/code/core/Mage/Page/Block/Welcome.php

to app/code/local/Mage/Page/Block/Welcome.php

tohtml

if (empty($this->_data['welcome'])) {
    if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
        $this->_data['welcome'] = $this->__(' hi %s% youre loggin in. <a href="%s">logout?</a>', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()),Mage::helper('customr')->getLogoutUrl());
    } else {
        //$this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
    $this->_data['welcome'] = $this->__('hi visitor,  to %s! <a  href="%s">Log<a> in or <a href="%s">register</a>', $this->escapeHtml(Mage::app()->getStore()->getFrontendName()),Mage::helper('customer')->getLoginUrl(),Mage::helper('customer')->getRegisterUrl());

    }
}

return $this->_data['welcome'];
0

Take a look at How do I change the welcome message in Magento 1.9+ the proper way?

Then make changes to

/**
 * Get block messsage
 *
 * @return string
 */
protected function _toHtml()
{
    if (empty($this->_data['welcome'])) {
        if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
            //change from
            //$this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getFirstname()));
            //to
            $this->_data['welcome'] = $this->__('hi visitor, welcome to %s! . <a href="%s">Log in</a> or <a href="%s">register</a>', $this->escapeHtml(Mage::app()->getStore()->getName();), Mage::helper('customer')->getLoginUrl(),Mage::helper('customer')->getRegisterUrl();
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.