I want to get custom URL from magento helper in this way:
<action
method="addLink"
translate="label title"
module="customer">
<label>About Us</label>
<url
helper="customer/getAboutUsUrl">
about
</url>
<title>About Us</title>
<prepare/>
<urlParams/>
<position>1</position>
</action>
So what I did is define a function getAboutUsUrl() under local directory within Customer Helper Directory. But it does not return the base url as I expected.
What do I have to do to get the baseurl with about us link?
Thanks
You should use cms/page/getPageUrl helper method and pass CMS-page identifier as its parameter like in the following example:
<action
method="addLink"
translate="label title"
module="customer">
<label>About Us</label>
<url helper="cms/page/getPageUrl"><pageId>about</pageId></url>
<title>About Us</title>
<prepare/>
<position>1</position>
</action>
Related
I have to assign custom attributes from drop down menu. means we have lots of books and i create custom attribute for languages like English,Hindi,Punjabi etc. i have tried this
$product_id = Mage::getModel('catalog/product')->load(23340);
echo "Product Name".$product_id->getName();
$product_id->setStoreId(1)->setData(('book_lang'),24)->save();
where 24 is the id of my custom drop down attribute (for English) it works but it not shown in filter attributes.
any response is precious...
hi for custom option check magento admin section and
in catalog.xml see this
<block type="core/template_facade" name="product.info.container1" as="container1">
<action method="setDataByKey">
<key>alias_in_layout</key>
<value>container1</value>
</action>
<action method="setDataByKeyFromRegistry">
<key>options_container</key>
<key_in_registry>product</key_in_registry>
</action>
<action method="append">
<block>product.info.options.wrapper</block>
</action>
<action method="append">
<block>product.info.options.wrapper.bottom</block>
</action>
</block>
<block type="core/template_facade" name="product.info.container2" as="container2">
<action method="setDataByKey">
<key>alias_in_layout</key>
<value>container2</value>
</action>
<action method="setDataByKeyFromRegistry">
<key>options_container</key>
<key_in_registry>product</key_in_registry>
</action>
<action method="append">
<block>product.info.options.wrapper</block>
</action>
<!-- <action method="append"><block>product.info.options.wrapper.bottom</block></action>-->
</block>
and check the product view.phtml for $this->getChildChildHtml('container2', '', true, true) please provide me some more information may be i will suggest you proper
and for filter try this $productCollection->addAttributeToFilter('costume_attribute_name', $productId);
How can i add another element after <li>
So i can get this tree structure <ul><li><span><a>Logout</a></span></li></ul>
Currently my rendered html is looking like this. I want to have span element to do bit more with logout. I have tried a lot but no luck. Please help. Thank you
<ul class="links">
<li class="first last">
Logout
</li>
</ul>
layout to top.links is
<customer_logged_in>
<reference name="account.links">
<action method="addLink" translate="label title" module="customer">
<label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
</action>
<action method="removeLinkByUrl">
<url helper="customer/getRegisterUrl" />
</action>
</reference>
If i am changing the links.phtml then change will apply for all the links or else i need to put if else in there but i needed it only for logout. so what is the best way to do that?
Is this achievable using addLinks method?
You can do this using the beforeText and afterText parameters, like this:
<action method="addLink" translate="label title" module="customer">
<label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
<beforeText><![CDATA[<span>]]></beforeText>
<afterText><![CDATA[</span>]]></afterText>
</action>
Which will modify your link to look something like this:
<li class="first last">
<span>Logout</span>
</li>
You can create your own template (a copy of links.phtml) and apply it only for Top Links.
Do it like this in your theme's local.xml:
<default>
<reference name="top.links">
<action method="setTemplate">
<template>page/template/my_links.phtml</template>
</action>
</reference>
<default>
Then copy page/template/links.phtml and rename it to page/template/my_links.phtml and do whatever you need inside that new template file. It will be only used to render Top Links, not for any other links
I am trying to have different css for login register and login links. But as they are being added using template_links block and they are automatically rendered and no template file for specific one, I am unable to achieve this.
<block type="page/template_links" name="account.links" as="accountLinks"/>
At the moment I tried changing the css but obviously css rules are getting assigned to all of it at the same time.
How can I achieve this please suggest something. Thank you
can I do that using layout?
<customer_logged_in>
<reference name="account.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>2</position></action>
<action method="removeLinkByUrl"><url helper="customer/getRegisterUrl" /></action>
</reference>
</customer_logged_in>
<!--
Load this update on every page when customer is logged out
-->
<customer_logged_out>
<reference name="account.links">
<action method="addLink" translate="label title" module="customer"><label>Login</label><url helper="customer/getLoginUrl"/><title>Login</title><prepare/><urlParams/><position>1</position></action>
<action method="removeLinkByUrl" ifconfig="enterprise_invitation/general/registration_required_invitation"><url helper="customer/getRegisterUrl" /></action>
<!-- <action method="addLink" translate="label title" module="customer"><label>register</label><url helper="customer/getRegisterUrl" /><title>register</title><prepare/><urlParams/><position>100</position><li/><a/><before_text> or </before_text><after_text>.</after_text></action> -->
</reference>
<remove name="wishlist_sidebar"></remove>
<remove name="reorder"></remove>
<remove name="top.menu" />
</customer_logged_out>
<!--
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="head">
<action method="addJs"><script>jquery/jquery.js</script></action>
</reference>
<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>
</customer_account_login>
current theme links look like this
------EDIT-----
After placing class in aparam It is still applying same old css rules as in the html showing no class element. I have place the .logout-link class in the same theme in custom and style.css but still no luck. It is not finding this class and not even it is showing in chrome developer tools.
<customer_logged_in>
<reference name="account.links">
<action method="addLink" translate="label title" module="customer">
<label>Log Out</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<aParams>class="logout-link"</aParams>
</action>
<action method="removeLinkByUrl"><url helper="customer/getRegisterUrl" /></action>
</reference>
<div class="header-links-wrapper">
<ul class="links">
<li class="first last">Log Out</li>
</ul>
</div>
You can apply a class with the addLink method using the following:
<liParams/>
<aParams>class="My Class Name"</aParams>
<beforeText/>
<afterText/>
So for example, to add a class to your logout link, you can do this:
<action method="addLink" translate="label title" module="customer">
<label>Log Out</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title><prepare/>
<urlParams/>
<position>2</position>
<liParams/>
<aParams>class="logout-link"</aParams>
<beforeText/>
<afterText/>
</action>
Then you just add a css definition for logout-link
I have a working link being added to the top.links block like this:
<block type="page/template_links" name="top.links" as="topLinks">
<action method="addLink">
<label>About Us</label>
<url helper="mymodule/getAboutUsUrl"/>
<title>About Us</title>
<prepare/>
<urlParams/>
<position>20</position>
</action>
</block>
Eventually I wanted getAboutUsUrl to turn into getExternalSiteUrl. I want that one function to take parameters. For instance, getExternalSiteUrl('about-us') which would then return something like /the/url/about-us. However, I can't seem to find a way to send a helper class parameters in a Layout XML file. I searched for other modules doing this already, and couldn't find one in the Customer module where I searched.
Can anyone help?
<block type="page/template_links" name="top.links" as="topLinks">
<action method="addLink">
<label>About Us</label>
<url helper="mymodule/getAboutUsUrl">
<arg>Now with more args!</arg>
<!-- will result in the string being passed as first arg -->
</url>
<title>About Us</title>
<prepare/>
<urlParams/>
<position>20</position>
</action>
</block>
Note that helpers do not extend Varien_Object, therefore your method will need to explicitly define the getAboutUsUrl() method.
I have to add Register link in the top menu links
So i did this, but i dont know whats the helper for register. Please help me
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</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>10</position></action>
</reference>
</customer_logged_in>
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getLoginUrl"/><title>My Account</title><prepare/><urlParams/><position>100</position></action>
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getAccountUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
</reference>
<remove name="wishlist_sidebar"></remove>
<remove name="reorder"></remove>
</customer_logged_out>
What you were doing is almost correct, but instead of customer/getAccountUrl you should use customer/getRegisterUrl.
So basically you should add the following xml line in customer_logged_out\reference
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getRegisterUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
So your code will look like this:
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</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>10</position></action>
</reference>
</customer_logged_in>
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getLoginUrl"/><title>My Account</title><prepare/><urlParams/><position>100</position></action>
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getRegisterUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
</reference>
<remove name="wishlist_sidebar"></remove>
<remove name="reorder"></remove>
</customer_logged_out>
Hope this helps anyone.
Use customer/getRegisterUrl as your helper to get the registration URL. This means that Magento do something like this:
$helper = Mage::helper("customer"); // gets Mage_Customer_Helper_Data
$url = $helper->getRegisterUrl();
Hope that helps.
Thanks,
Joe
<action method="addLink"
translate="label title"
module="customer">
<label>
Register
</label>
<url helper="customer/getCreateUrl"/>
<title>Register</title>
<prepare/>
<urlParams/>
<position>100</position>
</action>