Closed ed29 closed 11 years ago
Hi,
It seems that the welcome message has been hard coded in a Block file: app/code/Core/Mage/Page/Block/Html/Header.php
making impossible to make it an esi block by default. That's a typical Magento "WTF? moment".
One way to solve this problem is to create a new block that will contain your welcome message.
Edit your local.xml
file, add something like:
<reference name="header">
<block type="page/html" name="my_welcome_message" template="my_module/my_welcome_message.phtml">
<action method="setEsi">
<params>
<cache_type>per-client</cache_type>
</params>
</action>
</block>
</reference>
Create a template file in my_module/my_welcome_message.phtml
:
<?php
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
echo $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
}
?>
then, in app/design/frontend/your_package/your_theme/template/page/html/header.phtml
, find the line saying <?php echo $this->getWelcome() ?>
and replace it by <?php echo $this->getChildHtml("my_welcome_message") ?>
Its really help full for me and working also.Thanks
Magento Varnish cache the welcome message,it's a problem;change to per-client mode would be good.