Magento My Account Layout XML Problem

后端 未结 2 1865
耶瑟儿~
耶瑟儿~ 2021-02-02 02:21

I\'m having issues getting the customer.xml layout file to work properly for the customer\'s \"my account\" pages.

The navigation links and the previously ordered items

相关标签:
2条回答
  • 2021-02-02 03:00

    In response to dolu (for anyone else who has this problem), if you put Alan's module in app/code/community, you need to edit app/etc/modules/Alanstormdotcom_Layoutviewer.xml to use the "community" codePool. The module expects to be installed at app/code/local by default (at least the version linked to Alan's answer here).

    0 讨论(0)
  • 2021-02-02 03:14

    First things first. Make sure you've cleared out your Magento application cache. All layout XML is cached by Magento, so dropping a new file in there isn't enough to trigger any changes.

    It sounds like your left hand column isn't rendering. Here's a few possible reasons for this

    1. Your root template to is being set to something other than the two column left layout

    2. A <remove /> tag is being injected into the layout somewhere that's zapping your left column

    3. Your "left" block is being overridden so that it doesn't have the child blocks it needs to properly render

    So, step 1 is to figure out which of the three this is. Place some arbitrary but noticeable text in all your php/phtml files (i tend towards something like <h1>one</h1>, <h1>two</h1>, etc.) so you can tell which files are actually being loaded.

    There's also a template debug setting in

    System->Configuration->Developer->Debug->Template Path Hints
    

    which does something similar. If you want to use this you'll need to drill down to a specific configuration scope (you can't set it on default)

    While doing either of these won't point to the direct problem, they will (hopefully) let you rule out individual causes.

    There's an important thing to keep in mind about layouts. The names of those XML files are arbitrary. They way layouts work is all the layout XML is combined into one giant XML file. Then, for each request, this large XML file is reduced depending on what "handles" a page request has. A handle is something like <default> or <checkout_cart_index>. In other words, something in any of your other layout files may be causing you problems on the checkout page, not just things in customer.xml.

    It's also possible that the Magento site you're working with has a controller or two that's overridden, which would change the layout handles that Magento looks for with any page request.

    Point being, there's a number of things that could be causing this, and we need to peek inside Magento's internals. Install this module in your development environment (it's an experimental debugging thing I'm working on)

    http://alanstorm.com/2005/projects/Layoutviewer.tar.gz

    When you have it up and running, load a page in your store with the following query string

    http://magento.example.com/customer/account/?showLayout=handles
    

    This will display the handles magento uses on any request. You should see a list of something like

    1. default
    2. STORE_bare_us
    3. THEME_\frontend_default_default
    4. customer_account_index
    5. customer_logged_in

    If number 4 is something different (companyname_modulename_customer_account_index), that means your site has a custom controller for this request. If that's the case, you'll want to look for tags in your layouts inside <companyname_modulename_customer_account_index> that may be overriding what you want to do.

    Next, load a Magento URL with the following query string

    http://magento.example.com/customer/account/?showLayout=page
    

    You should see an XML file being rendered in the browser. This is you request's final layout XML. Look for a tag (most likely named root) with an output attribute set

    <block type="page/html" name="root" output="toHtml" template="page/2columns-left.phtml">
    

    The output attribute means this is the template that Magento will start rendering with. If this isn't your two column layout, you're closer to solving your problem.

    Next, look for a module named left inside the root module

    <block type="core/text_list" name="left" as="left" ignore="1"/>
    

    If this has an ignore attribute, there will probably be a corresponding tag

    <remove name="left"/>
    

    somewhere in your layout. You'll want to remove this.

    Also, make sure that your root block actually has a child block with the name left.

    <block type="page/html" name="root" output="toHtml" ... >
        ...
        <block type="core/text_list" name="left" as "left" />
        ...
    </block>
    

    Finally, and this is more a sanity check

    http://magento.example.com/checkout/cart/?showLayout=package
    

    Specifying "package" in the showLayout query string parameter will show you your entire package layout. This is all your layout.xml files combined into one. You can use this to make sure magento knows about the XML you're adding (cache), and to make sure you're editing the correct files. You can also example each handle section to look for unexpected layout intrusctions that are giving you the results you're not happy with.

    0 讨论(0)
提交回复
热议问题