Как удалить ссылки из top.liknks при входе/выходе в Magento 1.6.2

Я провел хороший поиск и нашел теги customer_logged_in и customer_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>

Но это не работает. Может кто-нибудь объяснить, почему это не работает? Это сводит меня с ума!


person eb_Dev    schedule 25.05.2012    source источник


Ответы (2)


Удаление ссылок в 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>
person pkoltermann    schedule 29.03.2013
comment
У меня тоже работает, но только с теми тегами, которые вы разместили, а не с <default>. - person Louis B.; 29.04.2014
comment
работает, убедитесь, что вы включили его <url helper="customer/getLoginUrl"/>, а не <url>customer/account/login/</url> - person Claudiu Creanga; 20.07.2015

Хорошо, я нашел причину, во-первых, это теги верхнего уровня, и их не следует помещать в тег по умолчанию, а во-вторых, он просто не работал в local.xml, поэтому я поместил код вверху customer.xml и это работает удовольствие. Примечание. Я удалил xml, который добавлял ссылки в top.links, так как это, похоже, ему мешает.

Рабочий 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>
person eb_Dev    schedule 25.05.2012