I need to hide a custom block on all checkouts (onepage and cart).
How should I edit the checkout.xml to hide it?
I tried <remove name="footer_newsletter"/> but it doesn't work. The strange thing is that if I put <remove name="footer" /> all the footer is hidden.
So where is the problem? On blocks section the ID and name is footer_newsletter so it's not wrong.
First remove the changes you have done on checkout.xml for Add local.xml to your theme layout folder.
For example in default magento theme it would be in app/design/frontend/default/default/layout
To your theme's layout folder add local.xml. In this local.xml Write following code:
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_cart_index>
<reference name="footer">
<remove name="footer_newsletter"/>
</reference>
</checkout_cart_index>
<checkout_onepage_index>
<reference name="footer">
<remove name="footer_newsletter"/>
</reference>
</checkout_onepage_index>
</layout>
local.xml runs at the last after calling all design xml file. So it will override any changes done in any xml.
Try to put the block which you want to hide in Comment in the checkout.xml.
You may also try something like this in local.xml:
<your_desired_handle><!-- replace handle here -->
<reference name="parent_block_of_footer_newsletter"> <!-- replace with the name of the parent block that contains your footer_newsletter block -->
<action method="unsetChild"><alias>alias_of_footer_newsletter_block</alias></action> <!-- replace the alias with the value of "as" attribute of your footer_newsletter block, or it's name if it does not have an "as" attribute -->
</reference>
</your_desired_handle>
Related
I want to add some custom fields using my block.
Problem is that block is not rendering inside the form tag or before the submit button(see the screenshot 1).
This is the code of rendering the block on Account edit page:
<?xml version="1.0" encoding="UTF-8"?>
<layout version="1.0.0">
<customer_account_edit>
<reference name="my.account.wrapper">
<block type="customfield/Register" name="customfield_registrationnnn" template="vss_customfield/register.phtml" />
</reference>
</customer_account_edit>
</layout>
Just use before =" module name of magento".
You can insert your code before magento
Actually there is no hook/handle to insert new/custom fields in account edit form.
Either you can overwrite the customer/form/edit.phtml in your module's layout file.
1) Put below snippet in your module's layout XML.
<customer_account_edit>
<reference name="customer_edit">
<action method="setTemplate">
<template>yourModule/customer/form/edit.phtml</template>
</action>
</reference>
</customer_account_edit>
2) Copy your theme's
customer/form/edit.phtml
to
yourModule/customer/form/edit.phtml
3) Now in your new file, you can put your custom fields.
I have some troubles in /checkout/cart page with taking out two blocks:
- compare products block
- voting block
I cant remove them from right sidebar
at current layout xml
/layout/checkout.xml
There is only MY ONE adding template to right sidedar
<reference name="right">
my adding template code here
</reference>
also I have just removed all adding templates to right sidebar from
/layout/page.xml
and as a result I see these two blocks (compare and voting) at right bar anyway (
Let me know where can They be removed by me from ?
Thanks
I hope you're using local.xml to do your customizations.
In local.xml
<default>
<!--other codes-->
<remove name="catalog.compare.sidebar" />
<remove name="right.poll" />
<!--other codes-->
</default>
if need to remove from checkout - cart page only and retain on other pages then use <checkout_cart_index> handler instead of and use "unSetChild". Remember <remove> will completely remove the block.
I found out where was problem )
Magento layouts include one of this
/layout/poll.xml
and There I saw these lines
<!-- Mage_Poll -->
<reference name="right">
<block type="poll/activePoll" name="right.poll">
<action method="setPollTemplate"><template>poll/active.phtml</template><type>poll</type></action>
<action method="setPollTemplate"><template>poll/result.phtml</template><type>results</type></action>
</block>
</reference>
</default>
after commented it They disappeared )
I'm a newbie in Magento. I have a question. I config following the guide on this website
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-4-magento-layouts-blocks-and-templates
<layout version="0.1.0">
<default>
<block type="page/html" name="root" output="toHtml" template="magentotutorial/helloworld/simple_page.phtml" />
</default>
</layout>
But it doesn't work. But I fix <default> to <helloworld_index_index>, it run.
I don't understand this issue. What is the diffrent?
<default> and <helloworld_index_index> are known as "Layout Handles".
If you study page.xml file in a layout folder of your theme or default theme, you will find that <default> layout handle has already been assigned with a "Block element" of name root. So, defining the root Block element again in the same layout handle doesn't make any sense to magento.
If you want to use a same Block element in the same layout handle then you should refer it using the Block element type <reference> as shown below:
<layout version="0.1.0">
<default>
<reference name="root">
<!-- Your changes here -->
</reference>
</default>
</layout>
Anyway, coming to the point, <helloworld_index_index> layout handle worked for you because it doesn't have a block element root already assigned somewhere else in layout xml files.
I would like all my CMS pages (but not all pages) to use a custom template file, however when I use the setTemplate action in my local.xml file it's not changing the template. The block is rendering correctly but without the correct layout.
The XML I'm using right now is:
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<cms_page_view>
<reference name="root">
<action method="setTemplate"><template>page/cms-page.phtml</template></action>
</reference>
<reference name="right">
<block type="catalog/navigation" name="default_page_view" template="navigation/game-menu.phtml"/>
</reference>
</cms_page_view>
</layout>
What am I doing wrong?
You aren't doing anything wrong - your directive is being overridden by the entity data. For the reason why, see Mage_Cms_Helper_Page::_renderPage():
protected function _renderPage(/*...*/)
{
//snip...
$action->getLayout()->getUpdate()
->addHandle('default')
->addHandle('cms_page');
$action->addActionLayoutHandles();
if ($page->getRootTemplate()) {
$handle = ($page->getCustomRootTemplate()
&& $page->getCustomRootTemplate() != 'empty'
&& $inRange) ? $page->getCustomRootTemplate() : $page->getRootTemplate();
$action->getLayout()->helper('page/layout')->applyHandle($handle);
}
//snip...
}
So, your directive is being processed under the full action name handle cms_page_view, which is added via the $action->addActionLayoutHandles(); call. Whereas CMS pages are practically always saved via the admin with a root_template value, this value will always override file-based directives.
While it would be possible to update the data, it would be at risk of being overwritten when In order to provide an alternate template which will be preserved when the page is edited via the admin, it's necessary to specify some configuration values and some corresponding layout XML. In your custom module's config XML (or in app/etc/local.xml if this is a non-distributed change):
<global>
<page>
<layouts>
<cms_page_custom>
<label>Empty</label>
<template>page/cms-page.phtml</template>
<layout_handle>cms_page_custom</layout_handle>
</cms_page_custom>
</layouts>
</page>
</global>
This will provide the option to the select input during CMS page administration. To complete this work, in your custom layout XML:
<cms_page_custom>
<reference name="root">
<action method="setTemplate"><template>page/cms-page.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
<action method="setLayoutCode"><name>empty</name></action>
</reference>
</cms_page_custom>
I need to append the before attribute to a block via a layout update reference call.
This is my local.xml file:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="content">
<block type="page/html_wrapper" name="content.footer" as="contentFooter" translate="label" after="-">
<label>Content Footer</label>
<action method="setElementId"><value>content-footer</value></action>
<action method="setElementClass"><value>clear</value></action>
</block>
</reference>
</default>
<catalog_category_default>
<reference name="breadcrumbs.container">
<action method="unsetChild"><name>category.title</name></action>
</reference>
<reference name="content">
<block type="catalog/category_view" name="category.title" template="catalog/category/title.phtml" before="content.footer"/>
</reference>
</catalog_category_default>
</layout>
My problem is, on the content block I create a content.footer block that you can assign widgets to in admin. I use after="-" on the content.footer block so in my mind, should put it ALWAYS at the bottom of the content block but this is not the case.
When you view a catalog category and it inserts the category.products block in to the content block, it displays underneath the content.footer block. The only way to make it work is if I redefine it in my local.xml and include all the child blocks in category.products, and set before before="content.footer".
So I thought why can't I use a reference to category.products in the catalog_category_default layout and set the block's before attribute, I tried the following:
<reference name="category.products">
<action method="setBefore"><value>content.footer</value></action>
</reference>
Which had no affect.
I also noticed the setAttribute() function in Mage_Core_Block_Abstract which saw it's just a wrapper for setData() but thought I would try it anyway, still nothing:
<reference name="category.products">
<action method="setAttribute"><key>before</key><value>content.footer</value></action>
</reference>
Is it possible to do what I want? Does before/after only apply to blocks in the same reference?
Layout updates are processed in order of layout update handles. Your block is being added last to content but only for the default LUH. Other handles (catalog_product_view, catalog_category_layered, etc) are processed after this handle.
If you truly need a content footer everywhere and want to make sure that it is the last thing inside of the content div, you should add your block to the root node in the default handle and customize the root templates (directly under page/, e.g. page/1column.phtml) by adding a getChildHtml('your.block') call after the getChildHtml('content') call. This will ensure that your block is always immediately at the end of the content blocks.