2

I'm creating a local.xml for a new site. I'm working on the customer account pages and I'm finding that I have to repeat a lot of the same rules per page.

For the Sales Order History page I have

    <sales_order_history>
        <reference name="head">
           <action method="addCss">
               <stylesheet>css/custom/account.css</stylesheet>
           </action>
        </reference>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <remove name="customer.account.link.back" />
    </sales_order_history>

If there was a way to just save the xml inside the sales_order_history tags in a variable, eg. {xmlRules} = sales_order_history and then call it I think it would make the file much more readable.

  <sales_order_view>
     {xmlRules}
  </sales_order_view>

Has anyone done something like this before?

3

You can do it like this:

1) Define your layout XML under custom handle name:

<MY_XML_RULES>
    <reference name="head">
        <action method="addCss"><stylesheet>css/custom/account.css</stylesheet></action>
    </reference>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <remove name="customer.account.link.back" />
</MY_XML_RULES>

2) Apply it:

<sales_order_history>
    <update handle="MY_XML_RULES" />
</sales_order_history>

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.