How to move a block from content to custom place - magento

The block below is added to the bottom of content. I want this block to be called from within the catalog/product/view.phtml. So i can place it with $this->getChildHtml().
</PRODUCT_TYPE_bundle>
<reference name="content">
<block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom_bundle.phtml" translate="label">
<label>Bottom Block Options Wrapper</label>
<action method="insert"><block>product.tierprices</block></action>
<block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone_bundle.phtml"/>
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart_bundle.phtml"/>
</block>
</reference>
</PRODUCT_TYPE_bundle>
How to do this ? Do I add a new reference ? like :
<reference name="content">
<reference name="blockname">
<block></block>
</reference>
</reference>

Related

Magento swatches not loading in home page latest and featured products section

In my magento home page, latest products & featured products section's color swatches of products is not working. I tried with following code in home page Custom Layout Update XML but it did not work:
<reference name="content">
<block type="catalog/product_new" name="product_new" template="catalog/product/new.phtml">
<block type="core/text_list" name="product_list.name.after" as="name.after" />
<block type="core/text_list" name="product_list.after" as="after" />
<block type="core/text_list" name="product.info.options.configurable.renderers" as="attr_renderers" />
</block>
</reference>
<PRODUCT_TYPE_configurable translate="label" module="catalog">
<label>Catalog Product View (Configurable)</label>
<reference name="product.info">
<block type="catalog/product_view_type_configurable" name="product.info.configurable" as="product_type_data" template="catalog/product/view/type/default.phtml">
<block type="core/text_list" name="product.info.configurable.extra" as="product_type_data_extra" translate="label">
<label>Product Extra Info</label>
</block>
</block>
<block type="catalog/product_view_type_configurable" name="product.info.availability" as="product_type_availability" template="catalog/product/view/type/availability/default.phtml" />
</reference>
<reference name="product.info.options.wrapper">
<block type="catalog/product_view_type_configurable" name="product.info.options.configurable" as="options_configurable" before="-" template="catalog/product/view/type/options/configurable.phtml">
<block type="core/text_list" name="product.info.options.configurable.renderers" as="attr_renderers" />
<block type="core/text_list" name="product.info.options.configurable.after" as="after" />
</block>
</reference>
</PRODUCT_TYPE_configurable>
Please help me to solve this.
Try this for configurable products:
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list-no-toolbar.phtml">
<block type="core/text_list" name="product_list.name.after" as="name.after" />
<block type="core/text_list" name="product_list.after" as="after" />
<action method="setCategoryId"><category_id>3</category_id></action>
<action method="setColumnCount"><count>4</count></action>
<action method="setDefaultDirection"><dir>desc</dir></action>
</block>
</reference>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/configurableswatches/product-media.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/configurableswatches/swatches-list.js</name></action>
</reference>
<reference name="product_list.name.after">
<block type="core/template" name="product_list.swatches" template="configurableswatches/catalog/product/list/swatches.phtml" />
</reference>
<reference name="product_list.after">
<block type="configurableswatches/catalog_media_js_list" name="configurableswatches.media.js.list" />
</reference>

My custom option not working on Right panel on view page

I am working on a Magento store, the requirement is to move the custom option to right panel.
I already did it, by moving some lines in catalog.xml file.
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!--
<action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action>
<action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action>
<action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action>
-->
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
<block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
<label>Alert Urls</label>
</block>
<action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action>
<block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setItemLimit"><type>upsell</type><limit>4</limit></action>
</block>
<block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />
<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
</block>
<block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
</block>
<block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>
<block type="core/text_list" name="product.info.extrahint" as="extrahint" translate="label">
<label>Product View Extra Hint</label>
</block>
</block>
</reference>
<reference name="right">
<!--#####################################################-->
<block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label">
<label>Info Column Options Wrapper</label>
<block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/>
<block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
<action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action>
<action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action>
<action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action>
<action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action>
</block>
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
</block>
<block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label">
<label>Bottom Block Options Wrapper</label>
<action method="insert"><block>product.tierprices</block></action>
<block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/>
<action method="append"><block>product.info.addtocart</block></action>
<action method="append"><block>product.info.addto</block></action>
</block>
<block type="core/template_facade" name="product.info.container1" as="container1">
<action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action>
<action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
<action method="append"><block>product.info.options.wrapper</block></action>
<action method="append"><block>product.info.options.wrapper.bottom</block></action>
</block>
<block type="core/template_facade" name="product.info.container2" as="container2">
<action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action>
<action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
<action method="append"><block>product.info.options.wrapper</block></action>
<action method="append"><block>product.info.options.wrapper.bottom</block></action>
</block>
<action method="unsetCallChild"><child>container1</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
<action method="unsetCallChild"><child>container2</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
<!--#####################################################-->
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>
Now it is on right panel and price change also working fine,
But the problem is that when i am going to submit it by select one
it showing me an error like "Please specify the product required option(s)."
this is for unable to take the attribute vale.
like size (XL, XXL)
If any one know this, please help me thank you
The problem is that the options block appeares out of the main product form, and validator highlights you an error after submitting the form.
The solution
Do not move the options block out of the "product.info" block in layout, because this block contains the main product form. You need to modify catalog/product/view.phtml template to achieve the desired result.

Magento override nested block

I have my local.xml set up as follows:
<cms_index_index translate="label">
<reference name="content">
<block name="promos" type="page/html" template="cms/promos/homepage.phtml" as="promos" />
<block type="page/html_wrapper" name="home.footer">
<action method="setElementClass"><value>l-two-col group</value></action>
<block type="page/html_wrapper" name="home.footer.main">
<action method="setElementClass"><value>l-main</value></action>
<block type="page/html" name="featured_products" template="catalog/category/favourites.phtml" as="featured_products" />
</block>
<block type="page/html_wrapper" name="home.footer.side">
<action method="setElementClass"><value>l-sidebar</value></action>
<block type="vertnav/navigation" name="catalog.vertnav" as="vertnav" template="vertnav/left.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
</block>
</block>
</block>
</reference>
</cms_index_index>
I have the below code in a module layout xml file which is correctly replacing the 'promos' block but I can't get it to do the same for the block named "featured_products".
<cms_index_index translate="label">
<remove name="promos"></remove>
<reference name="content">
<block type="page/html" template="cms/promos/homepage-usa.phtml" as="promos" />
</reference>
</cms_index_index>
Does anyone know how I can replace the featured_products bloc in the same way as I have already done for the promos block?
I have tried:
<reference name="content">
<block type="page/html" template="cms/promos/homepage-usa.phtml" as="promos" />
<reference name="home.footer">
<reference name="home.footer.main">
<block type="page/html" name="featured_products1" template="catalog/category/favourites-usa.phtml" as="featured_products1" />
</reference>
</reference>
</reference>
Thanks in advance,
Dave
Whereas you are in local.xml, I'm not sure why you aren't just removing the directives. In any event:
<remove name="featured_products"/> or
<action method="unsetChild" block="home.footer.main"><child>featured_products</child></action>
You should always add a name attribute to your block.

Trouble displaying a custom block under the default cart block on the checkout/cart page

I have a custom block which I am trying to add below the default/template/checkout/cart.phtml on the checkout cart page.
I have block displaying using local.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="checkout.cart">
<reference name="content">
<block type="module/checkoutextras" name="checkoutextras" as="extras" template="fracture/module/checkoutextras.phtml" after="content" />
</reference>
</reference>
</default>
</layout>
the problem is that it's appearing above the cart.phtml, basically it appears to be ignoring the after="content" in the block definition, it also doesn't move if I use after="-".
The relevant part of checkout.xml looks like this:
<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/1column.phtml</template></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_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 type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>
</block>
</block>
</reference>
<block type="core/text_list" name="additional.product.info" translate="label">
<label>Additional Product Info</label>
</block>
</checkout_cart_index>
I must be missing something, but i've even tried after="checkout.cart", and adding the block directly to but in both cases the block won't render, it only renders if the content reference is included, but in the wrong place. How can I update local.xml so that the checkoutextras block will render below the cart?
This should work :
<?xml version="1.0"?>
<layout>
<checkout_cart_index><!-- You just need to update the layout for the cart page, so you can use the corresponding action name -->
<reference name="content"><!-- A single reference to the wrapping "content" block is enough (you want to put content below the cart, not inside) -->
<block type="module/checkoutextras" name="checkoutextras" as="extras" template="fracture/module/checkoutextras.phtml" after="-" />
</reference>
</checkout_cart_index>
</layout>

Magento - Add CMS Block to One Page

I have this code in a xml layout file:
<reference name="left">
<block type="blog/blog" name="left.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/left">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
I want to add a cms static block to the blog pages using this code:
<block type="cms/block" name="brand_list">
<action method="setBlockId"><block_id>brand_list</block_id></action>
</block>
If I add it in directly after this line:
<reference name="left">
It works but it is then displayed on every page. How can I get it to show only on the blog pages?
Thanks.
Edit: Here is the entire xml file:
<layout version="0.1.0">
<default>
<reference name="footer_links">
<block type="blog/blog" name="add.blog.footer">
<block type="blog/tags" name="blog_tags" />
<action method="addFooterLink" ifconfig="blog/menu/footer"></action>
</block>
</reference>
<reference name="right">
<block type="blog/blog" name="right.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/right" ifvalue="1">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="left">
<block type="blog/blog" name="left.blog.menu" before="-">
<action method="setTemplate" ifconfig="blog/menu/left">
<template>aw_blog/menu.phtml</template>
</action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="top.links">
<block type="blog/blog" name="add.blog.link">
<action method="addTopLink" ifconfig="blog/menu/top"></action>
<block type="blog/tags" name="blog_tags" />
</block>
</reference>
<reference name="head">
<action method="addItem"><type>skin_css</type><name>aw_blog/css/style.css</name></action>
</reference>
</default>
<blog_index_index>
<reference name="content">
<block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
</reference>
</blog_index_index>
<blog_index_list>
<reference name="content">
<block type="blog/blog" name="blog" template="aw_blog/blog.phtml"/>
</reference>
</blog_index_list>
<blog_post_view>
<reference name="content">
<block type="blog/post" name="post" template="aw_blog/post.phtml">
<block type="socialbookmarking/bookmarks" name="bookmarks" template="bookmarks/bookmarks.phtml"/>
</block>
</reference>
</blog_post_view>
<blog_cat_view>
<reference name="content">
<block type="blog/cat" name="cat" template="aw_blog/cat.phtml" />
</reference>
</blog_cat_view>
<blog_rss_index>
<block type="blog/rss" output="toHtml" name="rss.blog.new"/>
</blog_rss_index>
</layout>
if it's going inside a section then it will be applied to all pages, you want to put the and its contents inside the sections (there'll be the listing page and individual post pages - the sections should already exist in the aw_blog.xml file
It appears on all pages, because you probably put the code in the section of the layout xml. Just put into a section named after the route where it should appear.
So try:
<blog>
<reference name="left">
<block type="cms/block" name="brand_list">
<action method="setBlockId"><block_id>brand_list</block_id></action>
</block>
</reference>
</blog>
Change XML inside folder theme/layout for example page.xml add something like this to header:
<block type="page/html_header" name="header" as="header">
<!-- ... some origin code ... -->
<block type="page/html" name="custom_block" as="flashHeader" template="customer/custom_header.phtml"/>
</block>
Create file customer/custom_header.phtml with your custom html code.
Inside template page/html/header.phtml you can add something like this:
$dataCurrentPage = $this->getHelper('cms/page')->getPage()->getData();
$page_id = (isset($dataCurrentPage['identifier'])) ? $dataCurrentPage['identifier'] : null;
if ($page_id == 'home' ) { echo this->getChildHtml('flashHeader') }
Flash banner will be show only on homepage.
You can definitely use the custom layout update to place your own static block on left without any coding.
You need to create a static block and then put its reference into custom layout update
<reference name="left">
<block type="cms/block" name="my_left_block" before="-">
<action method="setBlockId"><block_id>my_left_block</block_id></action>
</block>
to view an example follow the link below
https://lampjs.wordpress.com/2015/07/06/magento-add-static-cms-block-to-category-page-on-left/

Resources