Magento 1 – Including Customer Wishlist into Customer Account Index

blocksmagento-1wishlist

In customer->account->index I currently have the following Child Html (customer.account.dashboard.extra, info, address). My idea is to include other child html into that page to enhance current customer view when they log into the system and are redirected to their account info.

I copied the information from wishlist.xml:

<block type="wishlist/customer_wishlist" name="customer.wishlist" template="wishlist/view.phtml">
    <block type="wishlist/customer_wishlist_items" name="customer.wishlist.items" as="items" template="wishlist/item/list.phtml">
        <block type="wishlist/customer_wishlist_item_column_image" name="customer.wishlist.item.image" template="wishlist/item/column/image.phtml" />
        <block type="wishlist/customer_wishlist_item_column_comment" name="customer.wishlist.item.info" template="wishlist/item/column/info.phtml">
            <action method="setTitle" translate="title">
                <title>Product Details and Comment</title>
            </action>
        </block>
        <block type="wishlist/customer_wishlist_item_column_cart" name="customer.wishlist.item.cart" template="wishlist/item/column/cart.phtml">
            <action method="setTitle" translate="title">
                <title>Add to Cart</title>
            </action>
            <block type="wishlist/customer_wishlist_item_options" name="customer.wishlist.item.options" />
        </block>
        <block type="wishlist/customer_wishlist_item_column_remove" name="customer.wishlist.item.remove" template="wishlist/item/column/remove.phtml" />
    </block>
    <block type="core/text_list" name="customer.wishlist.buttons" as="control_buttons">
        <block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.share" template="wishlist/button/share.phtml" />
        <block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.toCart" template="wishlist/button/tocart.phtml" />
        <block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.update" template="wishlist/button/update.phtml" />
    </block>
</block>

and include that information into local.xml inside <customer_account_index translate="label">

then I placed <?php echo $this->getChildHtml('customer') ?> inside customer/account/dashboard.phtml

But no results are displayed. My main idea is to know which steps do I have to follow to include particular codes into other pages. (like: modify xml, include in phtml.., etc).

Best Answer

Ensure that your block customer.wishlist is included in local.xml under the correct layout handle (customer_account_index). Then attach your wishlist block to the dashboard block:

<customer_account_index>
    <reference name="customer_account_dashboard">
        <block type="wishlist/customer_wishlist" as="wishlist" name="customer.wishlist" template="wishlist/view.phtml">
            <!-- rest of your imported layout XML here -->
        </block>
    </reference>
</customer_account_index>

This will make it accessible in the template when you call for it. Then, render it with:

<?php echo $this->getChildHtml('wishlist'); ?>

I call for wishlist because that's the alias (as) defined in the wishlist block node.

Related Topic