9

顧客の「マイ アカウント」ページで customer.xml レイアウト ファイルを正しく機能させるのに問題があります。

通常はページの左側にあるナビゲーション リンクと以前に注文したアイテムはページに表示されませんが、xml ファイルで参照名を「コンテンツ」に変更すると表示されます (ただし、明らかに右側にあります)。参照しているテンプレート (2columns-left.phtml) を確認しましたが、getChildHtml('left') が正しい位置にあります。

問題を引き起こしているブロック:

<customer_account>
    <!-- Mage_Customer -->
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    </reference>

    <reference name="left">
        <action method="unsetChild"><name>catalog.navigation.all</name></action>
        <action method="unsetChild"><name>callout.sendcard</name></action>
        <action method="unsetChild"><name>callout.specialorder</name></action>
        <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>
        <block type="sales/reorder_sidebar" name="sale.reorder.sidebar" as="reorder" template="sales/reorder/sidebar.phtml"/>
        <remove name="tags_popular"/>
    </reference>
</customer_account>

これは基本的に、これが 100% 機能する別のサイトから直接コピーしたものです。考えられるすべてのことを試しましたが (たとえば、テンプレートとレイアウト xml の両方で参照の名前を変更するなど)、役に立ちませんでした。レイアウトが参照しているテンプレートは、「コンテンツ」領域に配置されたときに表示されるため、明らかに機能しています。

このマジェントのインストールはバージョン 1.3.1.1 です。

アドバイス等ありましたらよろしくお願いします...

更新:「global_messages」への参照を変更しようとしましたが、そこにも表示されません。「コンテンツ」セクションでのみ機能するようです。

更新 2: これらは、ページで "showLayout=page" クエリ文字列を使用して、Alan Storm の非常に便利なデバッグ モジュール (以下の彼の回答に記載されています) を使用した結果です。

    <?xml version="1.0"?>
<layout><block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
    <block type="page/html_head" name="head" as="head">
        <action method="addJs">
            <script>prototype/prototype.js</script>
        </action>
        <action method="addJs">
            <script>prototype/validation.js</script>
        </action>

        <action method="addJs">
            <script>paypoint/validation.js</script>
        </action>
        <action method="addJs">
            <script>scriptaculous/builder.js</script>
        </action>
        <action method="addJs">
            <script>scriptaculous/effects.js</script>

        </action>
        <action method="addJs">
            <script>scriptaculous/dragdrop.js</script>
        </action>
        <action method="addJs">
            <script>scriptaculous/controls.js</script>
        </action>
        <action method="addJs">

            <script>scriptaculous/slider.js</script>
        </action>
        <action method="addJs">
            <script>varien/js.js</script>
        </action>
        <action method="addJs">
            <script>varien/form.js</script>

        </action>
        <action method="addJs">
            <script>varien/menu.js</script>
        </action>
        <action method="addJs">
            <script>mage/translate.js</script>
        </action>
        <action method="addJs">

            <script>mage/cookies.js</script>
        </action>
        <action method="addCss">
            <stylesheet>css/reset.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/boxes.css</stylesheet>

        </action>
        <action method="addCss">
            <stylesheet>css/clears.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/menu.css</stylesheet>
        </action>
        <action method="addCss">

            <stylesheet>css/calendar-blue.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/styles.css</stylesheet>
        </action>
        <action method="addItem">
            <type>skin_css</type>

            <name>css/iestyles.css</name>
            <params/>
            <if>IE</if>
        </action>
        <action method="addItem">
            <type>skin_css</type>
            <name>css/ie7.css</name>

            <params/>
            <if>IE 7</if>
        </action>
        <action method="addItem">
            <type>skin_css</type>
            <name>css/ie7minus.css</name>
            <params/>

            <if>lt IE 7</if>
        </action>
        <action method="addItem">
            <type>js</type>
            <name>lib/ds-sleight.js</name>
            <params/>
            <if>lt IE 7</if>

        </action>
        <action method="addItem">
            <type>js</type>
            <name>varien/iehover-fix.js</name>
            <params/>
            <if>lt IE 7</if>
        </action>

        <action method="addCss">
            <stylesheet>css/print.css</stylesheet>
            <params>media="print"</params>
        </action>
    </block>
    <block type="page/html_header" name="header" as="header">
        <block type="page/template_links" name="top.links" as="topLinks"/>
        <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>

        <block type="core/template" name="top.nav" template="page/html/top.nav.phtml"/>
    </block>
    <block type="core/messages" name="global_messages" as="global_messages"/>
    <block type="core/messages" name="messages" as="messages"/>
    <block type="core/text_list" name="content" as="content"/>
    <block type="core/text_list" name="right" as="right"/>
    <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"/>
    <block type="core/text_list" name="before_body_end" as="before_body_end"/>
</block>

<block type="core/profiler" output="toHtml"/>
<reference name="top.links">
    <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>
<reference name="root">
    <action method="setTemplate">
        <template>page/2columns-left.phtml</template>
    </action>
</reference>
<reference name="top.menu">
    <block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>
</reference>
<reference name="footer_links">

    <action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map">
        <label>Site Map</label>
        <url helper="catalog/map/getCategoryUrl"/>
        <title>Site Map</title>
    </action>
</reference>
<reference name="footer_links">
    <action method="addLink" translate="label title" module="catalogsearch" ifconfig="catalog/seo/search_terms">
        <label>Search Terms</label>

        <url helper="catalogsearch/getSearchTermUrl"/>
        <title>Search Terms</title>
    </action>
    <action method="addLink" translate="label title" module="catalogsearch">
        <label>Advanced Search</label>
        <url helper="catalogsearch/getAdvancedSearchUrl"/>
        <title>Advanced Search</title>

    </action>
</reference>
<reference name="top.links">
    <block type="checkout/links" name="checkout_cart_link">
        <action method="addCartLink"/>
        <action method="addCheckoutLink"/>
    </block>
</reference>
<reference name="footer">
    <block type="cms/block" name="cms_footer_links" before="footer_links">
        <action method="setBlockId">

            <block_id>footer_links</block_id>
        </action>
    </block>
</reference>
<reference name="left">
    <block type="tag/popular" name="tags_popular" template="tag/popular.phtm" ignore="1">
        <action method="setTemplate">
            <template>tag/popular.phtml</template>
        </action>

    </block>
</reference>
<reference name="left">

</reference>
<reference name="before_body_end">
    <block type="googleanalytics/ga" name="google_analytics" as="google_analytics"/>
</reference>
<reference name="footer_links">
    <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled">
        <label>Contact Us</label>

        <url>contact-us</url>
        <title>Contact Us</title>
        <prepare>true</prepare>
    </action>
</reference>
<reference name="footer_links">
    <action method="addLink" translate="label title" module="rss" ifconfig="rss/config/active">
        <label>RSS</label>

        <url>rss</url>
        <title>RSS testing</title>
        <prepare>true</prepare>
        <urlParams/>
        <position/>
        <li/>
        <a>class="link-feed"</a>

    </action>
</reference>
<reference name="wishlist_sidebar">
    <action method="addPriceBlockType">
        <type>bundle</type>
        <block>bundle/catalog_product_price</block>
        <template>bundle/catalog/product/price.phtml</template>
    </action>

</reference>
<reference name="cart_sidebar">
    <action method="addItemRender">
        <type>bundle</type>
        <block>bundle/checkout_cart_item_renderer</block>
        <template>checkout/cart/sidebar/default.phtml</template>
    </action>
</reference>
<reference name="root">

    <action method="setTemplate">
        <template>page/2columns-left.phtml</template>
    </action>
</reference>
<reference name="left">
    <action method="unsetChild">
        <name>catalog.navigation.all</name>
    </action>
    <action method="unsetChild">

        <name>callout.sendcard</name>
    </action>
    <action method="unsetChild">
        <name>callout.specialorder</name>
    </action>
    <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>

    <block type="sales/reorder_sidebar" name="sale.reorder.sidebar" as="reorder" template="sales/reorder/sidebar.phtml"/>
    <remove name="tags_popular"/>
</reference>
<reference name="customer_account_navigation">
    <action method="addLink" translate="label" module="sales">
        <name>orders</name>
        <path>sales/order/history/</path>
        <label>My Orders</label>

    </action>
</reference>
<reference name="customer_account_navigation">
    <action method="addLink" translate="label" module="tag">
        <name>tags</name>
        <path>tag/customer/</path>
        <label>My Tags</label>
    </action>

</reference>
<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>
<reference name="cart_sidebar">

    <action method="addItemRender">
        <type>bundle</type>
        <block>bundle/checkout_cart_item_renderer</block>
        <template>checkout/cart/sidebar/default.phtml</template>
    </action>
</reference>
<update handle="customer_account"/>
<reference name="content">
    <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">

        <block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
        <block type="core/template" name="customer_account_dashboard_top" as="top"/>
        <block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
        <block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
        <block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
        <block type="core/template" name="customer_account_dashboard_info1" as="info1"/>
        <block type="core/template" name="customer_account_dashboard_info2" as="info2"/>
    </block>
</reference>

<reference name="right">
    <action method="unsetChild">
        <name>catalog_compare_sidebar</name>
    </action>
</reference>
<reference name="customer_account_dashboard">
    <action method="unsetChild">
        <name>top</name>
    </action>

    <block type="sales/order_recent" name="customer_account_dashboard_top" as="top" template="sales/order/recent.phtml"/>
</reference>
<reference name="right">
    <action method="unsetChild">
        <name>right.poll</name>
    </action>
</reference>
<reference name="customer_account_dashboard">
    <action method="unsetChild">
        <name>customer_account_dashboard_info2</name>

    </action>
    <block type="tag/customer_recent" name="customer_account_dashboard_info2" as="info2" template="tag/customer/recent.phtml"/>
</reference>
<reference name="right">
    <action method="unsetChild">
        <name>right.newsletter</name>
    </action>
</reference>
<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>

</reference></layout>
4

2 に答える 2

19

まず最初に。Magento アプリケーションのキャッシュをクリアしたことを確認してください。すべてのレイアウト XML は Magento によってキャッシュされるため、そこに新しいファイルをドロップしても、変更をトリガーするのに十分ではありません。

左側の列がレンダリングされていないようです。これにはいくつかの考えられる理由があります

  1. ルート テンプレートが 2 列の左レイアウト以外に設定されています

  2. <remove /> タグがレイアウトのどこかに挿入され、左側の列がザッピングされています

  3. 「左」ブロックがオーバーライドされているため、適切にレンダリングするために必要な子ブロックがありません

したがって、ステップ 1 は、これが 3 つのうちのどれであるかを把握することです。すべての php/phtml ファイルに任意だが目立つテキストを配置して (私は <h1>one</h1>、<h1>two</h1> のようなものを好む傾向があります)、どのファイルが実際にロードされているかを確認できるようにします。 .

テンプレートのデバッグ設定もあります

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

これは似たようなことをします。これを使用する場合は、特定の構成スコープにドリルダウンする必要があります (デフォルトでは設定できません)。

これらのいずれかを実行しても直接的な問題は示されませんが、(うまくいけば) 個々の原因を除外できます。

レイアウトについては、留意すべき重要な点があります。これらの XML ファイルの名前は任意です。レイアウトが機能する方法は、すべてのレイアウト XML が 1 つの巨大な XML ファイルに結合されることです。次に、要求ごとに、ページ要求に含まれる「ハンドル」に応じて、この大きな XML ファイルが削減されます。ハンドルは <default> や <checkout_cart_index> のようなものです。つまり、customer.xml だけでなく、他のレイアウト ファイルの何かがチェックアウト ページで問題を引き起こしている可能性があります。

作業している Magento サイトにオーバーライドされたコントローラーが 1 つまたは 2 つある可能性もあります。これにより、Magento がページ要求で検索するレイアウト ハンドルが変更されます。

ポイントは、これを引き起こしている可能性のあるものがいくつかあり、Magento の内部を覗く必要があるということです。このモジュールを開発環境にインストールします (これは私が取り組んでいる実験的なデバッグ用のものです)

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

起動して実行したら、次のクエリ文字列を使用してストアにページを読み込みます

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

これにより、任意のリクエストで magento が使用するハンドルが表示されます。次のようなリストが表示されるはずです

  1. デフォルト
  2. STORE_bare_us
  3. THEME_\frontend_default_default_default
  4. customer_account_index
  5. customer_logged_in

番号 4 が異なる場合 (companyname_modulename_customer_account_index)、それはサイトにこのリクエスト用のカスタム コントローラーがあることを意味します。その場合は、レイアウト内の <companyname_modulename_customer_account_index> 内のタグを探して、やりたいことを上書きしている可能性があります。

次に、次のクエリ文字列を使用して Magento URL を読み込みます

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

ブラウザーで XML ファイルが表示されるはずです。これは、リクエストの最終的なレイアウト XML です。出力属性が設定されたタグ (おそらく root という名前) を探します。

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

output 属性は、これが Magento がレンダリングを開始するテンプレートであることを意味します。これが 2 列のレイアウトでない場合は、問題の解決に近づいています。

次に、ルート モジュール内で left という名前のモジュールを探します。

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

これが無視属性を持っている場合、おそらく対応するタグがあります

<remove name="left"/>

レイアウトのどこかに。これを削除する必要があります。

また、ルート ブロックに実際に名前が残っている子ブロックがあることを確認してください。

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

最後に、これはより健全なチェックです

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

showLayout クエリ文字列パラメーターで「package」を指定すると、パッケージ レイアウト全体が表示されます。これはすべての layout.xml ファイルを 1 つにまとめたものです。これを使用して、追加 (キャッシュ) する XML を magento が認識していることを確認し、正しいファイルを編集していることを確認できます。また、各ハンドル セクションを例にして、満足できない結果をもたらしている予期しないレイアウトの侵入を探すこともできます。

于 2009-07-06T17:08:07.340 に答える
2

Dolu への対応として (この問題を抱えている他の人のために)、Alan のモジュールを app/code/community に配置する場合、app/etc/modules/Alanstormdotcom_Layoutviewer.xml を編集して「community」の codePool を使用する必要があります。モジュールは、デフォルトで app/code/local にインストールされることを期待しています (少なくとも、ここで Alan の回答にリンクされているバージョン)。

于 2010-05-27T00:39:49.727 に答える