2

よく検索して、タグcustomer_logged_incustomer_logged_outタグを見つけましたが、正しく機能させることができません。これは、私の誤解によるものだと確信しています。

私の目標は、ユーザーがログインしていないときにログイン、アカウント、チェックアウトのリンクをブロックから非表示にしtop.linksユーザーログインしているときにそれらを表示することです。

local.xmlログインリンクを削除するために、ファイルの最後に次のように配置しました。

    <customer_logged_in>
        <reference name="top.links">
            <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
        </reference>
    </customer_logged_in>

</default>

しかし、それは機能しません。誰かがこれが機能しない理由を説明できますか?それは私を夢中にさせています!

4

2 に答える 2

7

私の場合、local.xml のリンクを削除するとうまくいきます。コードは次のとおりです。

<customer_logged_in>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
    </reference>
</customer_logged_in>
<customer_logged_out>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
    </reference>
</customer_logged_out>
于 2013-03-29T12:35:08.753 に答える
3

わかりました理由を見つけました。まず、それらは最上位のタグであり、デフォルトのタグに配置するべきではありません。次に、local.xmlで機能していなかったため、コードをcustomer.xmlの上部に配置し、それは御馳走になります。注: top.links にリンクを追加した xml を削除しましたが、これが干渉しているようです。

作業xml:

<!--
Load this update on every page when customer is logged in
-->

    <customer_logged_in>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="checkout"><label>My Cart</label><url helper="checkout/cart/getCartUrl"/><title>My Cart</title><prepare/><urlParams/><position>9</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>
            <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>
    </customer_logged_in>

<!--
Load this update on every page when customer is logged out
-->
    <customer_logged_out>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>Sign up</label><url helper="customer/getRegisterUrl"/><title>Register </title><prepare/><urlParams/><position>100</position></action>
            <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
            <action method="removeLinkByUrl"><url helper="checkout/url/getCheckoutUrl"/></action>
            <action method="removeLinkByUrl"><url helper="checkout/cart/getCartUrl"/></action>         
            <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
        </reference>
    </customer_logged_out>
于 2012-05-25T13:06:11.940 に答える