i need to add the orange block on 2 column customer account,
what is the best way to adding that block, if i do from the 2 column left phtml, just scared it will shown at all 2column type, from local xml, but i am not sure about the code
any suggestion will be appreciate, Thanks
enter image description here
-
Not sure if this is the best solution, but maybe it fits your needs. The example is for 3columns but you can addapt it to 2 columns with left sidebar. magentocommerce.com/boards/viewthread/180617Marius– Marius2014年04月10日 08:13:35 +00:00Commented Apr 10, 2014 at 8:13
-
This universalcoder.wordpress.com/2014/03/29/… can be helpful to you. you can create a new reference position and call it in customer page.Dexter– Dexter2014年04月10日 08:31:22 +00:00Commented Apr 10, 2014 at 8:31
4 Answers 4
What you could do would be for the customer account page, I assume the default, handle customer_account_index. Use a different template, so you know that this will only appear on this one page, and then add the block inside the root reference also.
<customer_account_index>
<reference name="root">
<action method="setTemplate"><template>your/new/template.phtml</template></action>
<!-- Add your new block here -->
</reference>
</customer_account_index>
This is possible with CMS configuration only and no code:
Create a static block for the content (the orange block)
Create a new widget instance (CMS> Widgets) and select your theme screenshot (2)
Add Layout Update for page "Customer My Account (All Pages)" and reference "Page Header" screenshot (3)
Select static block from (1) in "Widget Options": screenshot (4)
Save.
Clean cache.
let me explain magento blocks in details hope it will help you to understand complete block mechanism
Everything in magento is a module , so all the modules have their controllers which are used for url routing system . lets take an example of url e.g http://example.com/index.php/customer/account/index/
module routes in this way module_controller_action
as you can see here module is customer , controller is accountcontroller and action is indexaction (all magento controller action works in this manner e,g editAction = edit on URL deleteAction = delete). You can verify by visiting this path /app/code/core/Mage/Customer/controllers
also related xml can be found under /app/design/frontend/base/default/layout customer.xml
Magento Reference Block
Now its time to explain reference block as its name suggests reference block is help ful to give a reference to your block . Suppose you want to integrate your block in left postion of the store then you can easily call
<reference name="left">
<block type="core/template" after="-"
name="sleek" template ="Sleekaccordian/new.phtml" /></reference>
Reference Action Method
Under reference tag we can call functions as well using action method as per the given example for newsletter.xml
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="newsletter">
<name>newsletter</name><path>newsletter/manage/</path>
<label>Newsletter Subscriptions</label></action>
</reference>
this reference (customer_account_navigation) is defined under customer.xml
<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>
now as per the block class if you’ll visit
/app/code/core/Mage/Customer/Block/Account then you’ll find addLink function under Navigation.php
<customer_account_index translate="label">
<reference name="my.account.wrapper">
<block type="customer/account_dashboard_users" name="customer_account_dashboard_users" template="customer/account/dashboard/users.phtml" as="dashboardusers"/>
</reference>
</customer_account_index>
Above is just an example. This will call users.phtml file on dashboard