currency selector updating in local.xml - magento

I want to keep the currency selector in top. So i added this code in local.xml:
<default>
<reference name="header">
<block type="directory/currency" name="currency" before="catalog.leftnav" template="directory/currency.phtml"/>
</reference>
</default>
Now how can i remove currency selector from left, right position. I tried this:
<default>
<reference name="left">
<remove name="currency"/>
</reference>
</default>
It removes all currency selector!

You named your header block currency as well. I would try renaming that header block (try header.currency) and see if that does it for you.

To remove from search results left side bar I used this:
Commet this out from directory.xml
<catalogsearch_result_index>
<reference name="left">
<block type="directory/currency" name="currency" before="-" template="directory/currency.phtml"/>
</reference>
</catalogsearch_result_index>

<remove name="currency"/>
Removes curreny module.If you want to remove currency from left sidebar and use it somewhere,code must be
<default>
<reference name="left">
<action method="unsetChild"><name>currency</name></action>
</reference>
</default>

Related

Get a block type of a page Magento

I would like to know how to find the block type of some page example : the home page.
I have a problem in my homepage, I want to display some block, in the xml I declared my block in <cms_index_index> (local.xml) but if I put it in the <reference name="head"> it appears, if <reference name="content"> or <reference name="content"> it does not work . It seems to me that the type of block is not good.
xml:
<cms_index_index>
<reference name="root">
<block type="core/template" name="seconnecter_test" template="customer/form/test-seconnecter.phtml"/>
</reference>
</cms_index_index>
in the homepage 1column-full.phtml i called it like this:
<?php echo $this->getChildHtml('seconnecter_test');?>
You can use
<reference name="root">
<block type="core/template" name="seconnecter_test" output="toHtml" template="customer/form/test-seconnecter.phtml"/>
</reference>
When you give <reference name="content"> Their block type is core/text_list. this block type output their content automatically, you don't need to use getchildhtml().
In your local.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<cms_index_index>
<reference name="content">
<block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/>
</reference>
</cms_index_index>
</layout>
Place the template file at correct location, and the block will render at top of content.
Or try this go to cms->pages->homepage from admin panel. Add following in the layout update xml of design section
<reference name="content">
<block type="core/template" name="seconnecter_test" before="_" template="customer/form/test-seconnecter.phtml"/>
</reference>
refresh the cache.

Magento: <action method="unsetChild"> Not removing a block

I switch the display of Wishlist_Sidebar from right to left, using the following codes, but the sidebar remains in both right and left sidebar.
<reference name="right">
<action method="unsetChild"><name>wishlist_sidebar</name></action>
//.....
</reference>
<reference name="left">
<action method="insert"><blockName>wishlist_sidebar</blockName></action>
</reference>
How to fix this problem
I think the unsetChild function might operate using the alias (the as attribute rather than the name attribute. Try using...
<reference name="right">
<action method="unsetChild"><name>wishlist</name></action>
//.....
</reference>

Edit category lay-out, but apply parts to products

I've got a custom category view.phtml for this category:
http://www.touchfix.nl/onderdelen
The sub-categories use their parent's XML-update, which is:
<reference name="catalog_category_default">
<reference name="content">
<remove name="category.products" />
<block type="catalog/category_view" name="alphabase.parts" template="catalog/category/view.parts.phtml">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.parts.phtml"></block>
</block>
</reference>
</reference>
<reference name="right">
<remove name="cms_waaromkiezen" />
<block type="cms/block" name="block_speerpunten_onderdelen">
<action method="setBlockId"><block_id>block_speerpunten_onderdelen</block_id></action>
</block>
</reference>
<reference name="head">
<action method="addCss"><stylesheet>css/categoryblocks.css</stylesheet></action>
</reference>
I want to achieve that the changes to "right" are also applied to products in these categories.
But when I apply these changes to products too in category settings, the "content" reference screws up my page and it returns a blank page.
How can I reference the catalog_category view, so that the "content" update is only done when in category view and not in product view?
catalog_category_default isn't a reference, it's a handle
have you tried changing to:
<catalog_category_default>
I managed to do the trick with the following:
<reference name="content">
<reference name="category.products">
<action method="setTemplate"><template>catalog/category/view.repair.phtml</template></action>
<reference name="product_list">
<action method="setTemplate"><template>catalog/product/list.repair.phtml</template></action>
</reference>
</reference>
</reference>
<reference name="right">
<remove name="cms_waaromkiezen" />
<block type="cms/block" name="block_speerpunten_reparatie">
<action method="setBlockId"><block_id>block_speerpunten_reparatie</block_id></action>
</block>
</reference>
<reference name="head">
<action method="addCss"><stylesheet>css/categoryblocks.css</stylesheet></action>
</reference>
The difference was not to delete the blocks and add new ones with the correct template, but to change the template files of the corresponding items. I can now also refer to the product view block with <reference name="product.info">, which will be my next step.

How to remove std div in magento

I was trying to remove the "std div" from my magento home page, but unable to find the same any suggestion.
The div you are looking for is a page/html_wrapper block being added via the cms.xml layout file.
Here is the excerpt taken from app/design/frontend/base/default/layout/cms.xml:
<cms_page translate="label">
<label>CMS Pages (All)</label>
<reference name="content">
<block type="core/template" name="page_content_heading" template="cms/content_heading.phtml"/>
<block type="page/html_wrapper" name="cms.wrapper" translate="label">
<label>CMS Content Wrapper</label>
<action method="setElementClass"><value>std</value></action>
<block type="cms/page" name="cms_page"/>
</block>
</reference>
</cms_page>
So, there are a couple of ways to remove the div depending on how you develop your themes.
First option would be applicable if you use local.xml:
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
</cms_page>
Second option would be applicable if you copy the base layout files over:
Copy cms.xml from app/design/frontend/base/default/layout/cms.xml to app/design/frontend/your_package/your_theme/layout/cms.xml and edit the first layout snippet from above to the following:
<cms_page translate="label">
<label>CMS Pages (All)</label>
<reference name="content">
<block type="core/template" name="page_content_heading" template="cms/content_heading.phtml" />
<block type="cms/page" name="cms_page" />
</reference>
</cms_page>
This code helped me to remove "std" div from a single cms page,
put it to "Layout Update XML" section:
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
EDIT:
Drew asked a question which makes me realize that your questions was how to remove the div (not just remove the class of the div). Ideally it's like any other "move" operation in layout XML, which means unsetting a parent-child relationship (in this case the one between the cms.wrapper and cms_page) and setting the child to another block (content):
<?xml version="1.0"?>
<layout>
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<action method="insert">
<alias>cms_page</alias>
</action>
</reference>
</cms_page>
</layout>
My original response is below:
Drew has a lot of good information in his answer. I'll just point out that the block API has some nuance that can make the layout XML very clean.
In your local.xml:
<?xml version="1.0"?>
<layout>
<cms_page translate="label">
<reference name="cms.wrapper">
<action method="unsetElementClass" />
</reference>
</cms_page>
</layout>
Ref Mage_Page_Block_Html_Wrapper->_toHtml() and Varien_Object->__call()
Here is the solution you are finding :)
Put this xml code in Page -> Design -> Layout Update XML
<block type="page/html_wrapper" name="cms.wrapper" translate="label">
<label>CMS Content Wrapper</label>
<action method="setElementClass"><value>your_class_name</value></action>
<block type="cms/page" name="cms_page"/>
</block>
Cheers!
Saran

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.

Resources