0

I have created a custom module create/routing, with a controller RoutingController.php which has several actions index, upload, instagram and I would like to update the template for all of these actions to a custom file page/routing.phtml within my local.xml

For the customer/account module I would write:

<customer_account> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> </customer_account> 

However following the same method for my own module:

<create_routing> <reference name="root"> <action method="setTemplate"><template>page/routing.phtml</template></action> </reference> </create_routing> 

Does not change the template for any action.

I have also tried <create_routing_default /> and I know the setTemplate method works as if I add it directly to an action i.e. <create_routing_index /> the template is correctly updated.

I must be missing something fundamental here, do I need to declare something within my module to enable this functionality?

1 Answer 1

3

You are nearly there.

By default they will not look in create_routing. You still need to add something to each action handle like so;

<create_routing_index> <update handle="create_routing" /> </create_routing_index> 

This will inherit the xml declared in create_routing. You will need to do the same for each action.

The alternative is to programatically add another handle (create_routing) to the layout in an abstract function called by each of the controller actions. I prefer the xml route though.

2
  • Thanks @Smartie this works and is a little neater than my example, do you have any more info on that abstract function you mentioned, I have had a look through the AccountController for customer/account but cant see anything at a glance? Commented Sep 15, 2015 at 10:47
  • If you look through app/design/frontend/base/default/layout/customer.xml you will also see Magento using the xml way as above with <update handle="customer_account"/> Commented Sep 15, 2015 at 11:11

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.