Magento - local.xml not recognising customer_logged_out - magento

I am using Magento 1.7.0.2 and would like to show some links only when the customer is logged out.
If I add the below code to local.xml nothing happens (I am logged out):
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Test</label><url helper="customer/getLoginUrl"/><title>Test</title><prepare/><urlParams/><position>100</position></action>
</reference>
<remove name="reorder"></remove>
</customer_logged_out>
However as soon as I remove the customer_logged_out tags the link gets displayed (for everyone) ie:
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Test</label><url helper="customer/getLoginUrl"/><title>Test</title><prepare/><urlParams/><position>100</position></action>
</reference>
<remove name="reorder"></remove>
If I try to use customer_logged_in tags nothing gets displayed also.
Why are these logged_in/logged_out tags not working in local.xml?

Related

Magento Custom Extension To show my account links

I have created a Magento extension, to integrate OST Ticket into magenta. This is working great however the only issue I'm having is to display the "My Account" Links.
On my account dashboard I have the following links:
Account Dashboard
Support Tickets
Account Information
Address Book
My Orders
Billing Agreements
Recurring Profiles
My Product Reviews
My Wishlist
My Applications
Newsletter Subscriptions
My Downloadable Products
When I include the block into my extension using the following code:
<support_index_index>
<reference name="content">
<block type="support/list" name="support_list" template="support/list.phtml" />
</reference>
<reference name="left">
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="support/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>
<remove name="tags_popular"/>
<remove name="leftnav" />
</reference>
</support_index_index>
I only get 4 links:
Account Dashboard
Support Tickets
Account Information
Address Book
Can someone please explain to me why this would happen and how I can get around this?
Take a look # /app/design/frontend/default/default/layout/review.xml
<customer_account>
<!-- Mage_Review -->
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
</reference>
</customer_account>
See Magento - How to add/remove links on my account navigation?

How can I display only My account link in top links in magento?

I have displayed all links in footer and i want to display My account link only in header
So how can i do that.
Should i use static block from cms pages or block from xml file?
Can anyone please help me
Thanks in advance
Another way to add "My Account" link
goto app/design/frontend/default(or your theme package)/(theme folder)/page/html/header.phtml.
In this file you can add your custom 'li' tag and can put a link for "My Account" as Controller moves it to My Account PAGE.
One more way here for you :)
Open theme/layout/customer.xml file and then modify the section that shows customer links on all pages, to include a link home and also a link to other customer service pages that you have deemed necessary, e.g. ‘returns’ (if you get a lot of those enquiries...).
<default>
<!-- Mage_Customer -->
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Home</label><url></url><title>Home</title><prepare>true</prepare><urlParams/><position>5</position></action>
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>94</position></action>
<action method="addLink" translate="label title" module="customer"><label>Deliveries</label><url>deliveries</url><title>Deliveries</title><prepare>true</prepare><urlParams/><position>95</position></action>
<action method="addLink" translate="label title" module="customer"><label>Returns</label><url>returns</url><title>Returns</title><prepare>true</prepare><urlParams/><position>96</position></action>
<action method="addLink" translate="label title" module="customer"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare><urlParams/><position>97</position></action>
</reference>
</default>
Enjoy :)
Option 1:
The layout files are used to display links in the top.links block. You can remove them in the relevant xml files, and leave everything else as is, e.g. in checkout.xml you have something like:
<default>
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCartLink"></action>
<action method="addCheckoutLink"></action>
</block>
</reference>
</default>
If you remove the block then they would no longer show these two links in the top.links block.
Option 2:
The alternative is, as you say, to create a cms block and include this in your header instead. To include a cms block in a template file you can use
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('toplinksblock')->toHtml() ?>
Or if you want to use the layout system use this in the layout file:
<reference name="footer">
<block type="cms/block" name="sample_links">
<action method="setBlockId"><block_id>sample_links</block_id></action>
</block>
</reference>
then this in the template file:
<?php echo $this->getChildHtml('sample_links') ?>
Option 3:
Or just edit top.links.phtml.

Displaying error messages when two forms are integrated in the same magento page

I have the login form and register form, integrated in the same page. ie, in the login page itself.
I am having a problem in showing the error messages, as if error occurs in any one of the forms, then the error messages are displayed in both the login and register sections.
for example, suppose if we provide wrong login data to login, then the error message is displayed on the top of both the login and register forms, since both the forms are in the same page.
If we try to register with an already existing email address, then also, error message saying email already exists, displayed on the top of login form and register form.
My requirement is that i need to display the error message only in the corresponding form.
In order to integrate both login and register form in to the login page itself, i changed the file \app\design\frontend\anz\default\layout\customer.xml and it is as follows
Layout for customer login page
<customer_account_login translate="label">
<label>Customer Account Login Form</label>
<!-- Mage_Customer -->
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
</reference>
<!-- Mage_Customer -->
<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"/>
</customer_account_login>
I am a newbie in magento. Any help would be greatly appreciated.
I changed your code a little bit. Please tell me where your forms are rendered?
<customer_account_login translate="label">
<label>Customer Account Login Form</label>
<!-- Mage_Customer -->
<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_login" name="customer_form_login" template="customer/form/login.phtml"/>
<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"/>
</customer_account_login>
Welcome to Magento Theming :-)
First, it's generally a better practice to use local.xml layout file under your custom theme (it's not there by default, it's for the end implementer to use). This way, you won't have to needlessly merge changes into customer.xml to keep it up to date.
In your local.xml, you can use the <update /> directive to include the layout update xml from one handle into another (which is effectively what you are doing already):
<customer_account_login>
<update handle="customer_account_create" />
</customer_account_login>
You will need to customize your create template customer/form/register.phtml and remove its <?php echo $this->getMessagesBlock()->getGroupedHtml() ?> call.
I tried a simple way to achieve the requirement. There may be better ways to do this, but I think this one is simple.
I had created a hidden variable and I put those hidden variable in forms to identify which form is submitted. These hidden variable is passed as a parameter after completing the corresponding action. Then I provided an if block to display the messages according to the parameter value.
I did this all by overriding the Mage Customer module.

Add "My Cart" to top.links magento in local.xml or checkout.xml?

Two parts to this question:
How can I add My Cart to either local.xml or checkout.xml? I have a custom template, that never had it called. Looking for where it is being removed, but not sure I am looking in the right place.
I have tried adding to local.xml
<reference name="root">
<reference name="top.links">
<action method="addCartLink"></action>
</reference>
</reference>
But it breaks magento. Basically I have a soft add to cart and want to pull the default magento "My Cart" to the header, so the ajax updates on page like it does in the default magento template.
2nd par - Where does the code for "My Cart" live to tweak it?
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCartLink"></action>
</block>
</reference>
You may have to clear your cache.

how to add shopping cart url under top links in magento through customer.xml

I tried a lot to add shopping cart url in magento
please show me how to add shopping cart url under top links in magento through customer.xml
i did in this way.
<default>
<!-- Mage_Customer -->
<reference name="top.links">
<action method="addLink" translate="label title" module="checkout"><label>Shopping Cart</label><url helper="checkout/getShoppingCartUrl"/><title>Shopping Cart</title><prepare/><urlParams/><position>10</position></action>
</reference>
</default>
Try this:
<default>
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCheckoutLink"></action>
</block>
</reference>
</default>

Resources