I need to add 2 custom blocks, one on the cart page (below the totals) and one on the checkout complete page. I've searched the net and can find no information on how I can do this. These blocks will contain custom js and need to interact with a custom model. I know how to write the modules required but I'm stuck with the XML and where I should place the templates/layout.
Can someone please give me a very short example (the equivalent of a 'hello world' that displays a block on the cart page)?
2 Answers 2
I think it will help you:
<checkout_cart_index>
<reference name="head">
<action method="addJs"><script>new.js</script></action>
</reference>
<block type="core/template" name="new" as="new" template="new.phtml" after="checkout.cart.totals" />
</checkout_cart_index>
Just put this short code into your custom layout XML.
Better idea define a new layout file from you custom module config.xml file .
<frontend>
<layout>
<updates>
<custommodule>
<file>custommodule.xml</file>
</custommodule>
</updates>
</layout>
</frontend>
Then you need put this custommodule.xml file at app/design/frontend/YourPackage/YourTemplate/layout/
Now,you can add your template file (.phtml) using Page handler
We know that checkout cart page handler is checkout_cart_index and checkout success page is checkout_onepage_success.
on custommodule.xml.you need put this code:
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_cart_index>
<reference name="content">
<block type="core/template" name="Giveaname" as="GiveAliasename" template="YourPathlocation" />
</reference>
</checkout_cart_index>
<checkout_onepage_success>
<reference name="content">
<block type="core/template" name="Giveaname" as="GiveAliasename" template="YourPathlocationofTempkay" />
</reference>
</checkout_onepage_success>
</layout>
The advantage of custom layout file is if module disable then the template is not works.
-
Thank you @Amit that looks like what I was looking for. I'll give it a try this morning and let you know how it went.Greg Stanton– Greg Stanton2015年06月25日 06:32:57 +00:00Commented Jun 25, 2015 at 6:32