Question

I am trying to use this code, found here, in the header.phtml file on my Magento 1.9.x website. For some reason, even on the home page at .com/ or .com/?SID= it is still applying H3 where it should be H1.

Does anyone know why this might be happening? Do I need other info on the page?

<?php if ($this->getIsHomePage()):?>
  <h1 class="logo"><strong><?php echo $this->getLogoAlt(); ?></strong></h1>
  <?php else: ?>
  <h3 class="logo"><strong><?php echo $this->getLogoAlt(); ?></strong></h3>
  <?php endif ?>

This code is also running to test against false positives - This code works but is only doing an echo on the code, not actually rendering it to provide the alt text:

<div id="are-we-home" style="display: none; ">
  <?php if($routeName == 'cms' && $identifier == 'home') { echo 'You are in Homepage!'; } else { echo 'You are NOT in Homepage!'; } ?>
</div>
Était-ce utile?

La solution

It's a bug. I think you're getting bitten by the same issue this guy is: 'Is home page' condition with different store views in magento not working

Replace your homepage check with this:

<?php 
  $action = Mage::app()->getFrontController()->getAction()->getFullActionName();
  if ($action == 'cms_index_index'):
?>

  <h1 class="logo"><strong><?php echo $this->getLogoAlt(); ?></strong></h1>

<?php else: ?>

  <h3 class="logo"><strong><?php echo $this->getLogoAlt(); ?></strong></h3>

<?php endif; ?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top