2

I have an element in header.phtml that shows in every page but I want to hide it in specific pages like categories and products.

<ul id=tempMenu>
 <li>...</li>
</ul>

and the php code

<?php if(!Mage::registry('current_category')):?>
  <script>
    document.ready(function() {
      document.getElementById('tempMenu').style.display = 'none';
    });
  </script>
<?php endif; ?>

I'm really new to magento so if anyone can help me I'd appreciate it.

0

You don't need javascript for that.

Just wrap your ul with PHP logic in header.phtml.

Hide element on all category and product pages:

 <?php if (!(Mage::registry('current_category') || Mage::registry('current_product))):?>
   <ul id=tempMenu>
    <li>...</li>
   </ul>
 <?php endif; ?>
0

Replace your code with this:

<?php if(Mage::registry('current_category') || Mage::registry('current_product')):?>
  <script>
   jQuery(document).ready(function(){
      jQuery('#tempMenu').hide();
    });
  </script>
<?php endif; ?>
0

You can remove header block with custom layout update.

On your Admin Panel, Manage Categories -> Your Sepecific Category -> Custom Design -> Custom Admin Panel

<reference name="header">
   <remove name="header"/>
</reference>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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