Remove navigation links from My Account - magento

I am running Mage 1.5.0.1 and I am trying to remove the navigation links from the My Account section.
My local.xml has the following which works fine:
<customer_account>
<reference name="root">
<action method="setTemplate"><template>page/staticpage.phtml</template></action>
</reference>
<reference name="left">
<remove name="cart_sidebar" />
<remove name="catalog.compare.sidebar" />
</reference>
</customer_account>
When I try to add the following code the system throws and error:
<reference name="customer_account_navigation">
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
</reference>
Error
Invalid method Mage_Customer_Block_Account_Navigation::removeLinkByName
I saw this function in 1.4, is it not supported anymore or am I doing something wrong?

I had a similar problem, and I didn't want to comment out addLink node because we want to implement our changes in local.xml only. Ended up writing a small module to do it:
app\etc\modules\Stackoverflow_Customerlinks.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Stackoverflow_Customerlinks>
<active>true</active>
<codePool>local</codePool>
</Stackoverflow_Customerlinks>
</modules>
</config>
app\code\local\Stackoverflow\Customerlinks\Block\Account\Navigation.php:
<?php
class Stackoverflow_Customerlinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {
public function removeLinkByName($name) {
unset($this->_links[$name]);
}
}
app\code\local\Stackoverflow\Customerlinks\etc\config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<blocks>
<customer>
<rewrite>
<account_navigation>Stackoverflow_Customerlinks_Block_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
</global>
</config>
After that, you can simply make the changes through local.xml:
<customer_account>
<reference name="customer_account_navigation">
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
</reference>
</customer_account>
Have fun :)

By default, we don't have such method as "removeLink". Therefore, the trick is to remove the whole block using "unsetChild" approach and add the needed links block back with our own links added to it in local.xml
<customer_account translate="label">
<reference name="left">
<!--Unset the whole block then add back later-->
<action method="unsetChild"><name>customer_account_navigation</name></action>
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
<action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
<action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>My Orders</label></action>
<action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
<action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Favorite</label></action>
<action method="addLink" translate="label" module="newsletter"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
</block>
<remove name="catalog.compare.sidebar"/>
</reference>
</customer_account>

Just to inform you guys about all the links in the navigation menu.
To remove all links in local.xml:
<?xml version="1.0"?>
<layout version="0.1.0">
<customer_account>
<reference name="customer_account_navigation" >
<!-- remove the link using your custom method -->
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
<action method="removeLinkByName"><name>reviews</name></action>
<action method="removeLinkByName"><name>downloadable_products</name></action>
<action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>
<action method="removeLinkByName"><name>account</name></action>
<action method="removeLinkByName"><name>account_edit</name></action>
<action method="removeLinkByName"><name>address_book</name></action>
<action method="removeLinkByName"><name>orders</name></action>
<action method="removeLinkByName"><name>tags</name></action>
<action method="removeLinkByName"><name>wishlist</name></action>
<action method="removeLinkByName"><name>newsletter</name></action>
</reference>
</customer_account>
</layout>
Thanks for your answer Daniel Sloof

You can use that:
<customer_account>
<action method="unsetChild"><name>customer_account_navigation</name></action>
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
...
</block>
</customer_account>
Rewriting is not solution...

I just refactored account dashboard links and removed CSS nth-child selectors as I had before and instead changed app/design/frontend/default/your_theme/template/customer/account/navigation.phtml to this
<div class="block block-account">
<div class="block-title">
<strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
<ul>
<?php $_links = $this->getLinks(); ?>
<?php $_index = 1; ?>
<?php $_count = count($_links);
unset($_links['recurring_profiles']);
unset($_links['billing_agreements']);
unset($_links['reviews']);
unset($_links['tags']);
unset($_links['OAuth Customer Tokens']);
unset($_links['downloadable_products']);
?>
<?php foreach ($_links as $_link): ?>
<?php $_last = ($_index++ >= $_count); ?>
<?php if ($this->isActive($_link)): ?>
<li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
<?php else: ?>
<li<?php echo ($_last ? ' class="last"' : '') ?>><?php echo $_link->getLabel() ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
basically unset any unwanted links.

There are other various xml file that refer to <reference name="customer_account_navigation"> where you can copy the xml file to your layout directory and comment out the addLink node other than that, I see a removeLinkByUrl that you might try instead.

You can also, override declaration by empty link - without define 'path' and 'label', direcly in local.xml:
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink"><name>tags</name></action>
<action method="addLink"><name>newsletter</name></action>
</reference>
</customer_account>

Go to app/design/frontend/YourPackageName/YourThemeName/layout/, create a sales/ directory if there isn't one, and create an empty file or directory named billing_agreement.xml and recurring_profile.xml.
Cleanest method ever, no custom functions, no CSS hacking, no logic in template files.
This completely hides the Billing Agreements and Recurring Profiles features from the user.

This module makes functionality ordering or show the links of my own, does not make for layout and phtml overwrites the block and makes all the logic there.
http://www.magentocommerce.com/magento-connect/customer-navigation.html
The cleanest solution would be to make an overwrite of the box and add a method to remove links from layout.

My Account Navigation links comes from customer.xml file.
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
<action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
</block>

My apperoach is to bring power of css and avoid hevy code modifications.
E.G.
/* CUSTOMER ACCOUNT LEFT NAV DISABLER */
.block-content li:nth-child(4),
.block-content li:nth-child(5),
.block-content li:nth-child(6),
.block-content li:nth-child(8){display: none;}
Obviously change selectors to your themes customer navigation li, and use li:nth-child() sudo with number between parenthesis which you want to remove.
Use comments in customer.xml as well just in case u don't forget what you did 6 month down the line.

Related

How to call mini cart in footer in magento?

I want to call mini cart in footer.
i have to use below code in xml file
<reference name="footer">
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.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>
</reference>
or <?php echo $this->getChildHtml('top_cart') ?> in footer.phtml.
but its not working for me. please give me any idea for do it.
you name of block is footer_cart so
change
<?php echo $this->getChildHtml('top_cart') ?>
to
<?php echo $this->getChildHtml('footer_cart') ?>
other problem is you are calling the wrong file
change
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.phtml" before="-">
to
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/sidebar.phtml" before="-">

Magento, Static Block won't render?

this is my local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="banner" as="banner" translate="label">
<label>Banner Area</label>
</block>
</reference>
<reference name="bannerblock">
<block type="core/template" name="bannerblock" template="banner.phtml" />
</reference>
</default>
</layout>
this is my 1column.phtml
<?php echo $this->getChildHtml('banner') ?>
I am not sure why it is not rendered. I think it might have to do with the placement of banner.phtml
should I put in
app/design/frontend/x/x/template/
or inside
app/design/frontend/x/x/template/page/html/
how do magenta find out?
You are referencing "bannerblock" block from inside of "bannerblock". Try moving the "bannerblock" block delaration into the "root" reference node:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="banner" as="banner" translate="label">
<label>Banner Area</label>
</block>
<block type="core/template" name="bannerblock" template="banner.phtml" />
</reference>
</default>
</layout>

How can i display header only homepage in Magento?

I want to display header only homepage.
How can i disable header other page?
Hi If your website having one column layout then open the 1column.phtml file and
replace this line
<?php echo $this->getChildHtml('header') ?>
with this,
<?php $page= Mage::getSingleton('cms/page')->getIdentifier();?>
<?php if($page=='home'){ ?>
<?php echo $this->getChildHtml('header') ?>
<?php } ?>
If you want remove this header using xml then follow below steps
step1:create local.xml under app/design/frontend/yourpackage/yourtemplate/layout
code of local.xml is
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="root">
<remove name="headerone"/>
</reference>
</default>
<cms_index_index >
<reference name="root">
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
</block>
<block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
<label>Page Header</label>
<action method="setElementClass"><value>top-container</value></action>
</block>
</block>
</reference>
</cms_index_index>
</layout>
Step2:goto page.xml under app/design/frontend/yourpackage/yourtemplate/layout
Find <block type="page/html_header" name="header" as="header">
change it to
<block type="page/html_header" name="headerone" as="headerone">
You could do this quite easily without any code changes by adding a <remove /> line for the header block in your local.xml and then in the home page layout, adding the header block to the home page in CMS under page layout in the design tab.
Layout is quite powerful in making such a custom mod.

magento - adding a block using local.xml

if I have a template in
app\design\frontend\base\default\template\dir\template.phtml
that look like this
<div class='block block-list'>
<div class='block-title'><strong><span>Some Block</span></strong></div>
<div class='block-content'>
<?php echo "my content"; ?>
</div>
</div>
How can I show it on a catalog page using local.xml? Shouldn't this code work?
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</default>
</layout>
I think you can not have custom layout handle<catalog_category_default translate="label"> inside default layout handle<default>
Correct me if I am wrong.
You have to use template reference name before that reference tag.
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<catalog_category_default translate="label">
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</catalog_category_default>
</default>
</layout>

Magento EE 1.11 - Customer Attributes Not Visible

Our client wants to add an 'Industry' dropdown to customer registration. We have created a new customer attribute, 'industry' and entered in the appropriate values.
It was not showing on the front-end. I looked into customer/form/register.phtml and it wasn't calling anything for attributes, so I pulled from enterprise/default/template/customer/form/register.phtml the following:
<?php $customerAttributes = $this->getChild('customer_form_user_attributes');?>
<?php if ($customerAttributes): ?>
<?php $customerAttributes->setShowContainer(false);?>
<?php $this->restoreSessionData($customerAttributes->getForm());?>
<?php echo $customerAttributes->toHtml()?>
<?php endif;?>
And then I added in the .xml update found in 'enterprise/layout/customer.xml':
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<block type="page/html_wrapper" name="customer.form.register.fields.before" translate="label">
<label>Form Fields Before</label>
<!--action method="setMayBeInvisible"><value>1</value></action-->
<action method="setElementClass"><value>rewards</value></action>
</block>
<block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_user_attributes">
<action method="setFormCode"><code>customer_account_create</code></action>
<action method="setEntityModelClass"><code>customer/customer</code></action>
</block>
<block type="enterprise_customer/form" template="customer/form/userattributes.phtml" name="customer_form_address_user_attributes">
<action method="setFormCode"><code>customer_register_address</code></action>
<action method="setEntityModelClass"><code>customer/address</code></action>
</block>
<reference name="content">
<block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml">
<action method="append"><block>customer.form.register.fields.before</block> <alias>form_fields_before</alias></action>
<action method="append"><block>customer_form_user_attributes</block> </action>
<action method="append"> <block>customer_form_address_user_attributes</block></action>
</block>
</reference>
<update handle="customer_form_template_handle"/>
At this point, the attributes are not visible on the front-end. If I perform:
<pre>
<?php print_r($customerAttributes->getUserDefinedAttributes()) ?>
</pre>
I am returned the array of attributes as I would expect. What am I missing here?
Found it. Needed this stuff in customer.xml. For some reason using the enterprise/default customer.xml wasn't working, but I added this in and it was good.
<customer_form_template_handle>
<reference name="content">
<block name="customer_form_template" type="enterprise_customer/form_template">
<action method="addRenderer">
<type>text</type>
<renderer_block>enterprise_customer/form_renderer_text</renderer_block>
<template>customer/form/renderer/text.phtml</template>
</action>
<action method="addRenderer">
<type>textarea</type>
<renderer_block>enterprise_customer/form_renderer_textarea</renderer_block>
<template>customer/form/renderer/textarea.phtml</template>
</action>
<action method="addRenderer">
<type>multiline</type>
<renderer_block>enterprise_customer/form_renderer_multiline</renderer_block>
<template>customer/form/renderer/multiline.phtml</template>
</action>
<action method="addRenderer">
<type>date</type>
<renderer_block>enterprise_customer/form_renderer_date</renderer_block>
<template>customer/form/renderer/date.phtml</template>
</action>
<action method="addRenderer">
<type>select</type>
<renderer_block>enterprise_customer/form_renderer_select</renderer_block>
<template>customer/form/renderer/select.phtml</template>
</action>
<action method="addRenderer">
<type>multiselect</type>
<renderer_block>enterprise_customer/form_renderer_multiselect</renderer_block>
<template>customer/form/renderer/multiselect.phtml</template>
</action>
<action method="addRenderer">
<type>boolean</type>
<renderer_block>enterprise_customer/form_renderer_boolean</renderer_block>
<template>customer/form/renderer/boolean.phtml</template>
</action>
<action method="addRenderer">
<type>file</type>
<renderer_block>enterprise_customer/form_renderer_file</renderer_block>
<template>customer/form/renderer/file.phtml</template>
</action>
<action method="addRenderer">
<type>image</type>
<renderer_block>enterprise_customer/form_renderer_image</renderer_block>
<template>customer/form/renderer/image.phtml</template>
</action>
</block>
</reference>
</customer_form_template_handle>
You should check template/customer/form/userattributes.phtml which is controlling user defined attributes. I don't know, does anybody touched this file? Check this first.
<?php foreach ($this->getUserDefinedAttributes() as $attribute):?>
<?php $attributeContent = $this->getAttributeHtml($attribute);?>
<?php if ($attributeContent): ?>
<li><?php echo $attributeContent;?></li>
<?php endif;?>
<?php endforeach;?>

Resources