Подтвердить что ты не робот

Удалить навигационные ссылки из моей учетной записи

Я запускаю Mage 1.5.0.1, и я пытаюсь удалить навигационные ссылки из раздела "Моя учетная запись".

У моего local.xml есть следующее, которое отлично работает:

 <customer_account>
    <reference name="root">
        <action method="setTemplate"><template>page/staticpage.phtml</template></action>
    </reference>
   <reference name="left">
        <remove name="cart_sidebar" /> 
        <remove name="catalog.compare.sidebar" />   
    </reference>
 </customer_account>

Когда я пытаюсь добавить следующий код, вызовы и ошибки системы:

   <reference name="customer_account_navigation">
    <action method="removeLinkByName"><name>recurring_profiles</name></action>
    <action method="removeLinkByName"><name>billing_agreements</name></action>
</reference>

Ошибка

Invalid method Mage_Customer_Block_Account_Navigation::removeLinkByName

Я видел эту функцию в 1.4, она больше не поддерживается или я делаю что-то неправильно?

4b9b3361

Ответ 1

У меня была аналогичная проблема, и я не хотел комментировать addLink node, потому что мы хотим реализовать наши изменения только в local.xml. Закончил писать небольшой модуль, чтобы сделать это:

Приложение\и т.д.\модули\Stackoverflow_Customerlinks.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Stackoverflow_Customerlinks>
            <active>true</active>
            <codePool>local</codePool>
        </Stackoverflow_Customerlinks>
    </modules>
</config>

Приложение\код\Local\Stackoverflow\Customerlinks\Block\Account\navigation.php:

<?php

class Stackoverflow_Customerlinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {

    public function removeLinkByName($name) {
        unset($this->_links[$name]);
    }

}

Приложение\код\Local\Stackoverflow\Customerlinks\и т.д. \config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <blocks>
            <customer>
                <rewrite>
                    <account_navigation>Stackoverflow_Customerlinks_Block_Account_Navigation</account_navigation>
                </rewrite>
            </customer>
        </blocks>
    </global>
</config>

После этого вы можете просто внести изменения через local.xml:

<customer_account>
    <reference name="customer_account_navigation">
        <action method="removeLinkByName"><name>recurring_profiles</name></action>
        <action method="removeLinkByName"><name>billing_agreements</name></action>
    </reference>
</customer_account>

Удачи:)

Ответ 2

По умолчанию у нас нет такого метода, как "removeLink". Поэтому трюк заключается в том, чтобы удалить весь блок с использованием подхода "unsetChild" и добавить необходимые блоки ссылок обратно с нашими собственными ссылками, добавленными к нему в local.xml

<customer_account translate="label">
        <reference name="left">
            <!--Unset the whole block then add back later-->
            <action method="unsetChild"><name>customer_account_navigation</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>
                <action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>My Orders</label></action>
                <action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
                <action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Favorite</label></action>
                <action method="addLink" translate="label" module="newsletter"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
            </block>
            <remove name="catalog.compare.sidebar"/>
        </reference>
    </customer_account>

Ответ 3

Просто, чтобы сообщать вам обо всех ссылках в меню навигации. Чтобы удалить все ссылки в local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
    <customer_account>
        <reference name="customer_account_navigation" >
                <!-- remove the link using your custom method -->
                <action method="removeLinkByName"><name>recurring_profiles</name></action>
                <action method="removeLinkByName"><name>billing_agreements</name></action>
                <action method="removeLinkByName"><name>reviews</name></action>
                <action method="removeLinkByName"><name>downloadable_products</name></action>
                <action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>

                <action method="removeLinkByName"><name>account</name></action>
                <action method="removeLinkByName"><name>account_edit</name></action>
                <action method="removeLinkByName"><name>address_book</name></action>
                <action method="removeLinkByName"><name>orders</name></action>
                <action method="removeLinkByName"><name>tags</name></action>
                <action method="removeLinkByName"><name>wishlist</name></action>
                <action method="removeLinkByName"><name>newsletter</name></action>

        </reference>
    </customer_account>
</layout>

Спасибо за ваш ответ Daniel Sloof

Ответ 4

Вы можете использовать это:

    <customer_account>
        <action method="unsetChild"><name>customer_account_navigation</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>
...
            </block>
     </customer_account>

Перезапись не является решением...

Ответ 5

Я просто переработал ссылки на панели учетных записей и удалил селектор nth-child CSS, как и раньше, и вместо этого изменил приложение /design/frontend/default/your _theme/template/customer/account/navigation.phtml на этот

<div class="block block-account">
<div class="block-title">
    <strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
    <ul>
        <?php $_links = $this->getLinks(); ?>
        <?php $_index = 1; ?>


            <?php $_count = count($_links); 
                unset($_links['recurring_profiles']); 
                unset($_links['billing_agreements']); 
                unset($_links['reviews']);
                unset($_links['tags']);
                unset($_links['OAuth Customer Tokens']);
                unset($_links['downloadable_products']); 
            ?>


        <?php foreach ($_links as $_link): ?>
            <?php $_last = ($_index++ >= $_count); ?>
            <?php if ($this->isActive($_link)): ?>
                <li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
            <?php else: ?>
                <li<?php echo ($_last ? ' class="last"' : '') ?>><a href="<?php echo $_link->getUrl() ?>"><?php echo $_link->getLabel() ?></a></li>
            <?php endif; ?>
        <?php endforeach; ?>
    </ul>
</div>

в основном отключает любые нежелательные ссылки.

Ответ 6

Существуют другие различные файлы xml, которые относятся к <reference name="customer_account_navigation">, где вы можете скопировать xml файл в ваш каталог макета и закомментировать addLink node, кроме этого, я вижу removeLinkByUrl, который вы можете попробовать вместо этого.

Ответ 7

Вы также можете переопределить декларацию пустой ссылкой - без определения "путь" и "метка", прямо в local.xml:

<customer_account>
    <reference name="customer_account_navigation">
        <action method="addLink"><name>tags</name></action>
        <action method="addLink"><name>newsletter</name></action>
    </reference>
</customer_account>

Ответ 8

Перейдите к app/design/frontend/YourPackageName/YourThemeName/layout/, создайте каталог sales/, если его нет, и создайте пустой файл или каталог с именем billing_agreement.xml и recurring_profile.xml.

Самый чистый метод, отсутствие пользовательских функций, хакерство CSS, отсутствие логики в файлах шаблонов.

Это полностью скрывает функции Billing Agreements и Recurring Profiles от пользователя.

Ответ 9

Этот модуль упорядочивает функциональность или показывает собственные ссылки, не делает для макета, а phtml перезаписывает блок и делает всю логику там.

http://www.magentocommerce.com/magento-connect/customer-navigation.html

  • Самое чистое решение - сделать переписку с полем и добавить метод для удаления ссылок из макета.

Ответ 10

Моя учетная запись Навигационные ссылки поступают из файла customer.xml.

            <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>

Ответ 11

Мой apperoach должен принести силу css и избежать модификаций кода hevy.

например.

/* CUSTOMER ACCOUNT LEFT NAV DISABLER */
.block-content li:nth-child(4),
.block-content li:nth-child(5),
.block-content li:nth-child(6),
.block-content li:nth-child(8){display: none;}

Очевидно, смените селектор на вашу личную навигацию пользователя li и используйте li: nth-child() sudo с номером между скобками, которые вы хотите удалить. Используйте комментарии в customer.xml, а также на случай, если вы не забудете, что вы сделали 6 месяцев по линии.