magento change block not working properly - magento

I am using magento 1.7
on my product page I have added related product on right sidebar.
there are other block also displayed on sidebar these are
-related product
-recently viewed product
-mycart
-paypal logo
Now I want related product to get displayed after mycart and paypal logo, right now it is displayed on top of right bar
I have used before and after but that is not working.
These is my code
paypal.xml
<reference name="right">
<block type="paypal/logo" name="paypal.partner.right.logo" after="cart_sidebar" template="paypal/partner/logo.phtml"/>
</reference>
catalog.xml
<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" after="paypal.partner.right.logo" template="catalog/product/list/related.phtml"/>
</reference>
checkout.xml
<reference name="right">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
how can I put mycart and paypal logo on top of right bar.

First you need to create or update your local.xml file IF you do not have a local.xml file you can create one in
app->frontend->[Package Name]->[Theme Name]->layout->local.xml
Once this is created you can copy exactly what I have in this post into that file for a start of how to use one.
DO ALL UPDATES THROUGH A LOCAL.XML file not through catalog.xml or checkout.xml !! This will make upgrades significantly easier later down the road. Additionally, you will be able to quickly see all changes you have made to your site in one file. This way I can see what you are actually updating.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="right">
<!-- <action method="unsetChild"><alias>catalog.product.related</alias></action> -->
<block type="catalog/product_list_related" name="catalog.product.related" after="-" template="catalog/product/list/related.phtml"/>
</reference>
</default>
</layout>
If you end up with two try uncommenting my action method.. I can't remember if you have to declare it in separate reference or within there because I didn't test this but give it a try

Related

How to remove the side bar cart from all pages but keep on product listing page in magento using local.xml

I have following code in local.xml
<default>
<remove name="cart_sidebar" />
</default>
To remove the sidebar cart from all pages but I want to keep it on product listing page and product details page.
How can I do this?
To achieve this you need to use Unset / Remove method.
To move a child block from one parent to another, reference the direct parent, call unsetChild on it, and then use the insert/add block method to assign the block instance as child to a different parent.
Try below code in your local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<default>
<reference name="right">
<action method="unsetChild"><name>cart_sidebar</name></action>
</reference>
</default>
<!--If you are not using layered navigation code start -->
<catalog_category_default>
<reference name="right">
<action method="insert"><block>cart_sidebar</block></action>
</reference>
</catalog_category_default>
<!--If you are not using layered navigation code end -->
<!--If you are using layered navigation code start -->
<catalog_category_layered>
<reference name="right">
<action method="insert"><block>cart_sidebar</block></action>
</reference>
</catalog_category_layered>
<!--If you are using layered navigation code end -->
<catalog_product_view>
<reference name="right">
<action method="insert"><block>cart_sidebar</block></action>
</reference>
</catalog_product_view>
</layout>

Add block using Custom Layout Updates to category

I am trying use the Custom Layout Update field of a category to add something to the left sidebar for just this category but can't quite get it to work. I had it working before so I know I can do it but then my client accidentally deleted the category.
This works, so I know I have the ability to add something - but I don't want a static block:
<reference name="left">
<block type="cms/block" name="Designer Sidebar" before="-">
<action method="setBlockId"><block_id>designer_sidebar</block_id></action>
</block>
</reference>
I want to include a phtml file from my theme folder and trying this, but can't get it to output anything:
<reference name="left">
<block type="cms/block" name="Designer Sidebar" before="-" template="catalog/category/view_sidebar.phtml" />
</reference>
<reference name="left">
<block type="core/template" name="Designer Sidebar" template="catalog/category/view_sidebar.phtml"/>
</reference>

Unable to remove core/textlist from head on the checkout

I'm having some trouble removing a block from the head on the checkout pages, I have added a core/textlist called before_head_end to the page head in the page.xml so that it is included on all pages:
Page.xml
<block type="page/html_head" name="head" as="head">
<block type="core/text_list" name="before_head_end" as="before_head_end">
<block type="core/template" name="ds_head_extras" as="ds_header_extras" template="dsingleton/headerextras/head_extras.phtml"/>
</block>
</block>
Now, I'm trying to remove that same block on the checkout pages only, so in my checkout xml i've tried 3 different ways to remove the block, but none of them works, can someone point out where i'm going wrong?
Checkout.xml
First Attempt:
<checkout_onepage_index translate="label">
<label>One Page Checkout</label>
<!-- Mage_Checkout -->
<reference name="head">
<remove name="before_head_end" />
</reference>
</checkout_onepage_index>
Second Attempt:
<checkout_onepage_index translate="label">
<label>One Page Checkout</label>
<!-- Mage_Checkout -->
<reference name="head">
<action method="unsetChild"><name>before_head_end</name></action>
</reference>
</checkout_onepage_index>
Third Attempt:
<checkout_onepage_index translate="label">
<label>One Page Checkout</label>
<!-- Mage_Checkout -->
<reference name="head">
<reference name="before_head_ends>
<action method="unsetChild"><name>ds_head_extras</name></action>
</reference>
</reference>
</checkout_onepage_index>
At first glance, all of them seem to be fine if you want to remove that block from checkout onepage.
The changes you made are going to apply only on checkout_onepage_index handle, so make sure you check checkout/onepage pages. For example, this is not going to affect the cart pages, because they are using checkout_cart_index handle.
Hope it helps, cheers.

Magento Block Positioning Never Works

Hello I always seem to have problems positions blocks.
Please see the website I am working on: http://www.hemptationz.com
I want the blocks on the left sidebar to appear in this order:
Facebook Block (callouts/facebook.pthml)
Currency Block (directory/currency.phtml)
Product Categories Block (vertnav/left.phtml)
Information Links Block (callouts/left_col.phtml)
This is the code I have in the XML layout files:
Catalog.xml
<reference name="left">
<block type="core/template" name="facebook" template="callouts/facebook.phtml" after="currency" />
<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml" after="catalog.vertnav" />
</reference>
vertnav.xml
<reference name="left">
<block type="vertnav/navigation" name="catalog.vertnav" template="vertnav/left.phtml" before="left.permanent.callout" />
</reference>
directory.xml
<layout version="0.1.0">
<!--
Category default layout
-->
<default>
<reference name="head">
<block type="core/template" name="optional_zip_countries" as="optional_zip_countries" template="directory/js/optional_zip_countries.phtml" />
</reference>
</default>
<catalog_category_default>
<reference name="left">
<block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
</reference>
</catalog_category_default>
<!--
Category layered navigation layout
-->
<catalog_category_layered>
<reference name="left">
<block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
</reference>
</catalog_category_layered>
<!--
Catalog Search layout
-->
<catalogsearch_advanced_index>
<reference name="left">
<block type="directory/currency" name="right_currency" before="facebook" template="directory/currency.phtml"/>
</reference>
</catalogsearch_advanced_index>
<catalogsearch_result_index>
<reference name="left">
<block type="directory/currency" name="currency" before="facebook" template="directory/currency.phtml"/>
</reference>
</catalogsearch_result_index>
<catalogsearch_advanced_result>
<reference name="right">
<block type="directory/currency" name="right_currency" before="facebook" template="directory/currency.phtml"/>
</reference>
</catalogsearch_advanced_result>
</layout>
Thanks hope you can help me.
The before and after attributes are limited in scope. They can only influence
The order of blocks within a particular sub-block when that sub-block is a core/test_list or other block that automatically renders sorted children.
You've not given enough context around how you're using the attributes in your question to give you specific advice, but I don't think you can do what you think you can with the feature. Be more explicit in your question and provide code example, along with "I expected foo, I got bar" style context, and will help you.
You want this order:
1. Facebook
2. Currency
3. Vertical Navigation
4. Information Links
but in your layout you have specified that facebook is after currency. If you want something to show first you have to use before="-" (in facebook link), then use after="facebook" for currency, after="currency" for catalog.vertnav and use after="-" for left.permanent.callout to position it on the bottom.

Magento local.xml layout file - overriding <remove name="left"/>

Is there any way to override, or re-add something that was removed via it's xml layout, using local.xml?
I've made a theme that's all based on one page layout, 2columns-left. But a lot of pages, such as the sitemap, are set to use a 1column layout. So for example, in catalog.xml, we have:
<catalog_seo_sitemap translate="label">
<label>Catalog Seo Sitemap (Common)</label>
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="page/template_container" name="seo.sitemap.container" template="catalog/seo/sitemap/container.phtml">
<block type="page/template_links" name="seo.sitemap.links" as="links" template="page/template/links.phtml"/>
<block type="page/html_pager" name="seo.sitemap.pager.top" as="pager_top" template="page/html/pager.phtml"/>
<block type="page/html_pager" name="seo.sitemap.pager.bottom" as="pager_bottom" template="page/html/pager.phtml"/>
</block>
</reference>
</catalog_seo_sitemap>
And in my local.xml, I can override the root template to use by adding:
<catalog_seo_sitemap>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
</catalog_seo_sitemap>
So it's now showing the sitemap in a 2column left layout. But there's nothing in the left column, as the < remove name="left" /> has removed it. I hate that I have to override this whole catalog.xml just to remove that, as it's a pain then when they update to a new version, I need to update all these extra layout files too.
So, is there any way to fix that using my local.xml? I think for the default Magento themes, they should have everything set to use the 3column layout, as that way you're free to remove whatever you don't need, but it's all there by default, so all changes can be done in the local.xml file.
Out of the box there's no way to unremove a layout block that's been removed by a previous call to <remove />. '
However, there's enough eventing in the Layout system that you can implement this yourself. And by "yourself", I mean I've created an experimental extension that adds a <unremove /> tag to the XML Layout system's grammer.
This has been asked before but no conclusion was reached. You can create a replacement block in your local.xml but there is no guarantee the child blocks added to it will be done so after your local changes.
<catalog_seo_sitemap>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<block type="core/text_list" name="left" as="left" translate="label">
<label>Left Column</label>
</block> <!-- Copied from page.xml -->
<block type="core/text_list" name="right" as="right" translate="label">
<label>Right Column</label>
</block> <!-- Copied from page.xml -->
</reference>
</catalog_seo_sitemap>
I've managed to do this by just changing the blocks name when reading it. Seems that if you remove a block and re-add it with the same name the remove label will apply to all blocks of the same name. In my case it was removing a account navigation and adding to the header.
<remove name="customer_account_navigation" />
<block type="customer/account_navigation" name="customer_account_nav" as="accountNavigation" template="customer/account/navigation.phtml">

Resources