2

我想更改默认设置 magento 显示中的顶部链接

我的帐户 | 我的愿望清单 | 我的购物车 | 结帐 | 登录

我需要更改顶部链接以仅在用户登录后显示“我的帐户”链接

谢谢帮助

4

3 回答 3

6

在 customer.xml 在你的主题之前它看起来像

 <default>
        <!-- Mage_Customer -->
        <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>
    </default>
<customer_logged_in>
    <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>
</customer_logged_in>

default从标签中删除我的帐户链接以Customer_logged_in 更改它

在 customer.xml 更改后

<default>
        <!-- Mage_Customer -->
        <reference name="top.links">

        </reference>
    </default>

<!--
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="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>

希望这对你有帮助。

于 2013-08-30T09:29:16.280 回答
0
<customer_logged_in>
<reference name="top.links">
    <action method="addLink" translate="label title">
        <label>Your Account</label>
        <url helper="customer/getAccountUrl" />
        <prepare/>
        <urlParams/>
        <liParams>
            <id>header-account-link</id>
        </liParams>
        <aParams/>
        <beforeText/>
        <afterText/>                 
    </action>
</reference>

于 2014-10-09T13:51:54.530 回答
0

我们可以很容易地做到这一点假设我们只需要在登录后显示My-Account链接,我们必须覆盖自定义主题中的authorization.phtml文件,我们可以根据我们的要求放置我们的逻辑。app/design/frontend/Namespace/自定义主题/Magento_Customer/templates/account/link/authorization.phtml

覆盖此文件后,我们可以输入我们的登录信息 -

 <?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Customer\Block\Account\AuthorizationLink $block */

$objectManagerlogin = \Magento\Framework\App\ObjectManager::getInstance();
$baseurl = $objectManagerlogin->get('Magento\Store\Model\StoreManagerInterface')->getStore(0)->getBaseUrl();
$dataPostParam = '';
if ($block->isLoggedIn()) {
    $dataPostParam = sprintf(" data-post='%s'", $block->getPostParams());
}
?>
<?php if($block->isLoggedIn() && $baseurl || $block->isLoggedIn() ) : ?>
 <li class="authorization-link" >
    <a href="<?php echo $baseurl .'customer/account/logout'; ?>">Sign Out</a>
</li>
 <li class="authorization-link custom-top-link-myaccount-mobile" >
   <a href="<?php echo $baseurl .'customer/account/'; ?>">My Account</a>
</li>
<?php else : ?>
 <li class="authorization-link" data-label="<?= $block->escapeHtmlAttr(__('or')) ?>">
    <a <?= /* @noEscape */ $block->getLinkAttributes() ?><?= /* @noEscape */ $dataPostParam ?>>
        <?= $block->escapeHtml($block->getLabel()) ?>
    </a>
</li>
 <?php endif; ?>

我希望这将有助于您在 Magento2 中根据自己的需要管理我的帐户部分

于 2020-07-11T12:18:23.300 回答