Magento custom breadcrumbs translation not not working - magento

Hello how can i translate my custom breadcrumbs on shopping cart page.
My checkout.xml code here for display breadcrumbs on shopping cart page.
<checkout_cart_index translate="label">
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb" >
<crumbName>home</crumbName>
<crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>
</action>
<action method="addCrumb" >
<crumbName>Shopping Cart</crumbName>
<crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title></crumbInfo>
</action>
</block>
</reference>
</checkout_cart_index>
Above code output on shoping cart page.
Home / Shopping Cart
I nedd to translate above label and title.
How i can solve this issu.
I already added translation text in Mage_Checkout.csv.
"Shopping Cart","Carrinho De Compras"
But now working translation text how can it done ?

You need to specify path to translatable item in arguments hiearchy. To do that, you add translate parameter in your action.
<action method="methodName" translate="foo">
<foo>I will be translated by Core module</foo>
</action>
If you want to manage your translation from Mage_Checkout.csv, you need to specify the translator module.
<action method="methodName" translate="foo" module="checkout">
<foo>I will be translated by Checkout module</foo>
</action>
But here is the trick: You are trying to translate an inner argument of crumbInfo. You need to use a dot seperator to make it happen. Also you can add multiple arguments to translate parameter by seperating them with space.
Here is the code for you;
<action method="addCrumb" module="checkout" translate="crumbInfo.label crumbInfo.title">
<crumbName>Shopping Cart</crumbName>
<crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title></crumbInfo>
</action>

It is completed by this code
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb" translate="crumbInfo.label crumbInfo.title">
<crumbName>home</crumbName>
<crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>
</action>
<action method="addCrumb" translate="crumbInfo.label crumbInfo.title">
<crumbName>Shopping Cart</crumbName>
<crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title></crumbInfo>
</action>
</block>
</reference>
</checkout_cart_index>
Get refrence from by this link

Related

Magento creating a custom template from backend category layout

I need to create a custom template with products categories. Which means under one category limited number of related products should be displayed. Under another category that category related products should be displayed. Also there should be a label which display those category names. As well as I need to add a link to view more products.
I am doing this through category layout (backend). I added the below code and tried.
<reference name="header">
<block type="core/template" name="header_nav" as="headerNav" template="page/html/headernav.phtml">
</block>
</reference>
<reference name="content">
<block type="catalog/product_list" name="product_list_flowers" template="catalog/product/list.phtml">
<action method="setData"><key>category_id</key><value>178</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
<block type="catalog/product_list" name="product_list_cakes" template="catalog/product/list.phtml">
<action method="setData"><key>category_id</key><value>179</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
</reference>
Category products are displaying. But this is not limiting the number of products. Also the header is not displaying. And I cannot add a link to this page.
Can anyone please help me on this. Thank You.
To be able to set limitation on Product Collection (since this differs from category to category in your case), find below the implementation:
<reference name="content">
<block type="catalog/product_list_flowers" name="product_list_flowers" template="catalog/product/list/flowers.phtml">
<action method="setData"><key>category_id</key><value>178</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
<block type="catalog/product_list_cakes" name="product_list_cakes" template="catalog/product/list/cakes.phtml">
<action method="setData"><key>category_id</key><value>179</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
</reference>
The above code will continue to display 4 columns with products.
Create block files (If this differs from category to category)
app/code/local/Namespace/Module/Block/Catalog/Product/List/Flowers.php
app/code/local/Namespace/Module/Block/Catalog/Product/List/Cakes.php
Override List.php (If all the categories require same limitation of products)
app/code/local/Namespace/Module/Block/Catalog/Product/List.php
 
<reference name="content">
<block type="catalog/product_list" name="product_list_flowers" template="catalog/product/list/flowers.phtml">
<action method="setData"><key>category_id</key><value>178</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
<block type="catalog/product_list" name="product_list_cakes" template="catalog/product/list/cakes.phtml">
<action method="setData"><key>category_id</key><value>179</value></action>
<action method="setColumnCount"><count>4</count></action>
</block>
</reference>
Below line no: 87, In this public function _getProductCollection()
...
$this->_productCollection = $layer->getProductCollection();
$this->_productCollection->setPageSize(10); //this will display only 10 products
...
Let me know if I was able to understand it correctly.
Happy Coding...

CMS page with layered navigation not working

I've added a CMS page wich shows all the products listed under the "All Products" category by creating a CMS page with a "two column with left sidebar" layout, and in the content tabs, I've added the following code:
{{block type="catalog/product_list" category_id="2" template="catalog/product/list.phtml"}}
I was reading about it and the layered navigation should be showing already. However, I've set "Is anchor" to yes, but it doesn't work. I can't make it to appear. What am I missing here? Is there a better way to create this catalog page?
Thanks in advance.
To display layered navigation on cms page you have to set root category to Is Anchor=Yes.
Please check the below link for calling layer navigation in CMS Page
http://www.webdesign-gm.co.uk/news/web-design/magento-web-design/layered-navigation-on-home-page-or-any-cms-page-magento.php
Or you can try this Design tab->Page Layout->Layout Update XML:
<reference name="left">
<!-- Layered Navigation Block -->
<block type="catalog/layer_view" name="catalog.leftnav" template="catalog/layer/view.phtml" >
<action method="setCategoryId"><category_id>40</category_id></action>
</block>
</reference>
<reference name="content">
<block type="catalog/product_list" name="home" template="catalog/product/list.phtml">
<!-- Product List View -->
<action method="setCategoryId"><category_id>40</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
Open CMS->Pages->[your page] in Magento Admin Panel.
Add the following layout instructions to Design tab->Page Layout->Layout Update XML
<block type="catalog/product_list" name="product_list"
template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>3</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar"
template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend">
<layout>empty</layout>
<count>6</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>one_column</layout>
<count>5</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>two_columns_left</layout>
<count>4</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>two_columns_right</layout>
<count>4</count>
</action>
<action method="addColumnCountLayoutDepend">
<layout>three_columns</layout>
<count>3</count>
</action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
<block type="catalog/layer_view" name="cms_layer" as="cms_layer" before="-">
<action method="setCategoryId"><category_id>3</category_id></action>
</block>
Also insert ID of desired category in 3 (2 times).
Open desired category of your store through Catalog->Manage Categories. Make sure that Is Anchor=Yes on Display Settings tab.
One possible reason layered navigation does not show is because you also need to configure your attributes to show in layered navigation.

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>

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

Change order of blocks via local.xml file

Is it possible to change the order of already existing blocks via the local.xml file?
I know you can change the order of a block with the after or before attribute, but how can one change those attributes of existing blocks.
For example, if I want to place the layered navigation block underneath the newsletter subscription block in the left column, how would I do that?
You need to perform a small trick, remove child block and add it in new position:
<reference name="parent.block.name">
<action method="unsetChild">
<alias>child_block_alias</alias>
</action>
<action method="insert">
<blockName>child.block.name</blockName>
<siblingName>name_of_block</siblingName>
<after>1</after>
<alias>child_block_alias</alias>
</action>
</reference>
This Layout XML instruction does what you want. Look at this short reference of parameters for insert method:
blockName is your block unique name across the layout, product.view for example
siblingName is an block unique name, that is already exists in insertion target block, used for positioning of your block. Leave empty to display it at the top or at the bottom.
after is a boolean identifier of block position. If equals to 1, then the block will be added after siblingName or in the bottom of the children list if siblingName is empty
alias is the alias of your block, if it is empty the name of block will be used.
Some Examples:
Move cart sidebar block after recently viewed products
<reference name="right">
<action method="unsetChild">
<alias>cart_sidebar</alias>
</action>
<action method="insert">
<blockName>cart_sidebar</blockName>
<siblingName>right.reports.product.viewed</siblingName>
<after>1</after>
</action>
</reference>
Move cart sidebar block before recently viewed products
<reference name="right">
<action method="unsetChild">
<alias>cart_sidebar</alias>
</action>
<action method="insert">
<blockName>cart_sidebar</blockName>
<siblingName>right.reports.product.viewed</siblingName>
<after>0</after>
</action>
</reference>
Move cart sidebar block at the end of the right block
<reference name="right">
<action method="unsetChild">
<alias>cart_sidebar</alias>
</action>
<action method="insert">
<blockName>cart_sidebar</blockName>
<siblingName></siblingName>
<after>1</after>
</action>
</reference>
Move cart sidebar block at the top of the left block
<reference name="right">
<action method="unsetChild">
<alias>cart_sidebar</alias>
</action>
</reference>
<reference name="left">
<action method="insert">
<blockName>cart_sidebar</blockName>
</action>
</reference>
Enjoy working with Magento!
You can remove previous layered navigation block and add a new layered navigation block after newsletter block.
<reference name="left">
<remove name="catalog.leftnav" />
<block type="catalog/layer_view" name="catalog.leftnavcustom" after="left.newsletter" template="catalog/layer/view.phtml"/>
</reference>
Note that I use a custom name for the new block.
The accepted answer didn't work for me (EE1.14) but something close to it, this:
<wishlist_index_index>
<reference name="customer.wishlist.items">
<action method="unsetChild">
<name>customer.wishlist.price</name>
</action>
<action method="insert">
<blockName>customer.wishlist.price</blockName>
<after>customer.wishlist.qty</after>
</action>
</reference>
</wishlist_index_index>

Resources