3

I have a template that needs to be only on account pages and checkout pages.

I have got a menu in the local.xml that is shown when a customer is logged in but I want to show it only on certain pages aswell.

1 Answer 1

3

You can target specific pages by using their respective handles.

Add the following to your local.xml

<checkout_cart_index>
    <reference name="header">
        <block type="menu/block" name="custom_menu" template="custommenu/template.phtml"/>
    </reference>
</checkout_cart_index>

<checkout_onepage_index>
    <reference name="header">
        <block type="menu/block" name="custom_menu" template="custommenu/template.phtml"/>
    </reference>
</checkout_onepage_index>

<customer_account>
    <reference name="header">
        <block type="menu/block" name="custom_menu" template="custommenu/template.phtml"/>
    </reference>
</customer_account>

<customer_logged_out>
    <remove name="custom_menu"/>
</customer_logged_out>

Guessing the menu would be added in the header of your webshop this will add it to the cart, checkout and customer account section ONLY for logged in users.

I've used the customer_logged_out handle to remove the menu when a user is not logged in. Somewhat along the lines of what you've discribed in your question.

Now you can call the menu by adding the following code in your header.phtml where you want to display the menu.

<?php echo $this->getChildHtml('custom_menu');?>
9
  • 1
    Does this go into local.xml?
    – M dunbavan
    Sep 13, 2013 at 13:53
  • Yes it does, should have mentioned this :) Sep 13, 2013 at 13:54
  • Will this automatically show in the header or will I need to call <?php echo $this->getChildHtml('my_account_menu_block') ?>?
    – M dunbavan
    Sep 13, 2013 at 13:55
  • You will need to call it. It will only be automatically added of a PHTML file has echo $this->getChildHtml() without a key in it. Sep 13, 2013 at 13:57
  • So adding <?php echo $this->getChildHtml('my_account_menu_block') ?> into my header will call the block but only on account pages and checkout pages?
    – M dunbavan
    Sep 13, 2013 at 13:59

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.