5

I am trying to implement an adjustment to the default .phtml files that are shipped with magento. I am a little confused as to how the .phtml files are altered without adjusting them directly, consequently I am failing to get this to work. The example I will use is the account dashboard heading (found on storeName.local/index.php/customer/account/index/) MY ACCOUNT, I'd like to change it to [USERSNAME]'S ACCOUNT.

To do this I have copied the contents of customer/account/navigation.phtml into the file path myNamespace/modulename/account/navigation.phtml on line 29 there is this code

<?php echo $this->__('My Account'); ?> my random text for testing

and added this to my modulename/layout.xml

    <modulename_index_index>
        <reference name="left">
            <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="namespace/modulename/account/navigation.phtml" />
        </reference>
    </modulename_index_index>

THEN

    <modulename_index_index>
        <reference name="customer_account_navigation">
            <action method="insert"><type>simple</type><block>customer/account_navigation</block><template>namespace/modulename/account/navigation.phtml</template></action>
        </reference>
    <modulename_index_index>

These methods have not worked. To be honest I didn't expect it to but the way I have read the posts is that I need to apply the code from the phtml file which I am overriding into my module, followed by the equivalent file path held in its default module.

How do I go about making adjustments

Pages viewed to try and resolve issue

try 1 try 2 try 3

8

As far as I know the heading is located in the file customer/account/dashboard.phtml. To overwrite this from your custom extensions layout XML, or the local.xml please add the following

<customer_account_index>
   <reference name="customer_account_dashboard">
      <action method="setTemplate"><template>[module]/customer/account/dashboard.phtml</template></action>
    </reference>
</customer_account_index>

This will change the template file used from the default file to your custom file which, in this case, would be located at app/design/frontend/[package]/[theme]/template/[module]/customer/account/dashboard.phtml

  • This is what I was trying to achieve, but I am unable to add my additional text with your suggested code, I edited customer.xml to make sure I was targeting the right location and using namespace/module/restOfThePath it worked, I applied this to local.xml and that had no effect. Where else would you suggest looking to resolve the issue? – tony09uk Oct 7 '13 at 12:05
  • might be that the view file is already overwritten somewhere. Did you try and turn on template hints to see if the origional file is used in your shop? – Sander Mangel Oct 7 '13 at 12:13
  • I had previously other overrides in local xml, within a default node (come to think about it I don't know why I didn't consider this option before), the suggestion you offered was placed in a default node by me, taking it out sees your code working perfectly, thanks – tony09uk Oct 7 '13 at 12:27
4

I may have confused you earlier with my overly long post.

Start by creating a new theme. Note the base theme is a folder called app/design/frontend/default/base/. Let's pretend your theme is "tony" and create a folder called app/design/frontend/default/tony/. Now go to the Magento admin, click on the menu System > Configuration, then click on Design. Fill the page in like this before saving.

enter image description here

Your new theme is now active but looks exactly like the base theme. Copy the file app/design/frontend/default/base/customer/account/navigation.phtml to app/design/frontend/default/tony/customer/account/navigation.phtml. Make some edits to the new file and look again at your site, it should have changed!

If not go to the admin menu System > Cache Management and turn off all caches until you have finished working on the site.

  • Although this is one way to do it OP was actually right on track with overwriting it from a custom extension which is, in my opinion, much cleaner. – Sander Mangel Oct 7 '13 at 11:18
  • It depends what you are trying to achieve. I like having both answers here for future reference and comparison. – clockworkgeek Oct 7 '13 at 11:22
  • You are absolutely right, it's good to state both options :) – Sander Mangel Oct 7 '13 at 11:23
  • I shall be trying this as a way to give myself a fuller understanding of what options are available to me in the future, thank you – tony09uk Oct 7 '13 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.