3

I created my custom CMS block in Magento, with identifier info_cart. I changed the checkout.xml file and the cart page now has to 2 columns with right sidebar (instead of 1 column).

<reference name="root">
        <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
    </reference>

I also added this piece of code

<reference name=checkout.cart>
  <block type=cms/block name=info_cart>
     <action method=setBlockId><block_id>info_cart</block_id></action>
  </block>
</reference>

Which displays the content from the custom block. But the content is displayed at the bottom of the page, not in the sidebar, on the right side of the page. Where should I put <?php echo $this->getChildHtml('info_cart'); ?> to be display on the right sidebar instead of bottom of the page?

EDIT: I update the text with the full cod of checkout.xml

<checkout_cart_index translate="label">
        <label>Shopping Cart</label>
        <remove name="right"/>
        <remove name="left"/>
        <!-- Mage_Checkout -->
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="addCrumb"><crumbName>home</crumbName><crumbInfo><label>Home</label><title>Home</title></crumbInfo></action>
            <action method="addCrumb"><crumbName>shopping_cart</crumbName><crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title></crumbInfo></action>
        </reference>
        <reference name="content">
            <block type="checkout/cart" name="checkout.cart">
                <action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
                <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
                <action method="chooseTemplate"/>
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>

                <block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
                    <label>Payment Methods Before Checkout Button</label>
                    <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                </block>

                <block type="page/html_wrapper" name="checkout.cart.form.before" as="form_before" translate="label">
                    <label>Shopping Cart Form Before</label>
                </block>

                <block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
                    <label>Payment Methods After Checkout Button</label>
                    <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                    <block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>
                </block>

                <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
                <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>

                <block type="core/text_list" name="checkout.cart.replace.crosssell" as="replace.crosssell" translate="label">
                    <label>Shopping Cart Sample Block Replace With Crosssell</label>
                </block>
                <block type="themeframework/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

                <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            </block>
        </reference>
        <block type="core/text_list" name="additional.product.info" translate="label">
            <label>Additional Product Info</label>
        </block>

        <reference name="right"> <!-- or left, whatever -->
        <block type="cms/block" name="info_cart">
            <action method="setBlockId"><block_id>info_cart</block_id></action>
        </block>
        </reference>
    </checkout_cart_index>
1

3 Answers 3

3

try below code

<reference name="right">
  <block type=cms/block name=info_cart>
     <action method=setBlockId><block_id>info_cart</block_id></action>
 </block>
</reference>

Right block has core/text_list type of block so you dont need to write <?php echo $this->getChildHtml('info_cart'); ?>

Edit

In your handler checkout_cart_index comment out below code

<remove name="right"/>
<remove name="left"/>

The above code responsible not to load left and right section

6
  • First I tried your suggestion but didn't work. The content from the custom block doesn't appear at all when I change reference name to right. Instead if the reference name is checkout.cart, the content is visible at the bottom of the page.
    – Radu C.
    Commented Feb 2, 2017 at 13:57
  • Can you please show your full code Commented Feb 2, 2017 at 13:58
  • I pasted the whole code from checkout.xml. I don't understand why it formats it so bad...
    – Radu C.
    Commented Feb 2, 2017 at 14:03
  • @raduc. got the problem you are adding reference with in reference add direct in checkout_cart_index Commented Feb 2, 2017 at 14:03
  • Commenting out <remove name="right"/> did the job! Thank you!
    – Radu C.
    Commented Feb 2, 2017 at 14:11
0

You can add a block in left side bar using this code:

<reference name="left_first"> <!-- use left_first instead of left for rwd theme-->
<block type="cms/block" name="info_cart" >
<action method="setBlockId"><block_id>info_cart</block_id></action>
</block>
</reference> 
2
  • I want the content from the info_cart to be visible only on the cart page. If I add the code you provided won't it display the content everywhere on the website?
    – Radu C.
    Commented Feb 2, 2017 at 14:02
  • You can put this on checkout. Xml. Do some effort yourself
    – Arunendra
    Commented Feb 2, 2017 at 14:11
0

Define this xml in local.xml

<reference name="right">
  <block type=cms/block name=right_cart>
     <action method=setBlockId><block_id>right_cart</block_id></action>
 </block>
</reference>

Then create a block with id 'right_cart' in admin.

Refresh the cache to view results.

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.