本文設有一個一步一步說明如何進行現實生活中的布局自定義任務。也就是說,它說明如何改變客戶賬戶鏈接布局Magento的商店頁面標題。
**移除客戶賬戶鏈接**
在他們的Orange主題,OrangeCo要轉換頭鏈接塊來下拉,它在亮度Magento的主題做的方式:

要做到這一點,他們需要換頭鏈接列表中有一個容器,并添加一個問候與列表前一個下拉箭頭。
默認情況下所呈現的標題鏈接看起來像以下:

需要 :

第1步:定義block
OrangeCo適用亮度的主題。使用說明中找到模板,布局和樣式,他們找出辦法,負責顯示的標題鏈接<Magento_Customer_module_dir>/view/frontend/layout/default.xml:
~~~
...
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="top.links">
<block class="Magento\Customer\Block\Account\Link" name="my-account-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">My Account</argument>
</arguments>
</block>
<block class="Magento\Customer\Block\Account\RegisterLink" name="register-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">Register</argument>
</arguments>
</block>
<block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml"/>
</referenceBlock>
</body>
</page>
~~~
第2步:定義模板
類似于它們所定義的前一步驟中的布局方式,OrangeCo限定其用于重新排列鏈接的模板:
~~~
<Magento_Customer_module_dir>/view/frontend/templates/account/customer.phtml
<?php if($this->customerLoggedIn()): ?>
<li class="customer welcome customer-welcome">
<span class="customer name" data-mage-init='{"dropdown":{}}' data-toggle="dropdown">
<span><?php echo $this->getCustomerName(); ?></span>
<button type="button" class="action switch"><span><?php echo __('Change')?></span></button>
</span>
<?php if($this->getChildHtml()):?>
<div class="customer menu customer-menu" data-target="dropdown">
<?php echo $this->getChildHtml();?>
</div>
<?php endif; ?>
</li>
<?php endif; ?>
~~~
步驟3:基地布局擴展添加一個block0塊
OrangeCo需要創建一個新的塊,也就是說,header.links,在header.panel容器,以移動鏈接那里。作為鏈路可以由不同的模塊被添加到該列表中,最好是此塊添加到Magento_Theme模塊的default.xml中頁配置。
So the following extending layout is added in the Orange theme:
~~~
app/design/frontend/OrangeCo/orange/Magento_Theme/layout/default.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header.panel">
<block class="Magento\Framework\View\Element\Html\Links" name="header.links">
<arguments>
<argument name="css_class" xsi:type="string">header links</argument>
</arguments>
</block>
</referenceContainer>
</body>
</page>
~~~
第4步:移除鏈接
要移動的鏈接,header.links的block,OrangeCo增加了一個擴展布局:
~~~
app/design/frontend/OrangeCo/orange/Magento_Customer/layout/default.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="header.links">
<block class="Magento\Customer\Block\Account\Customer" name="customer" template="account/customer.phtml" before="-"/>
<block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link-login" template="account/link/authorization.phtml"/>
</referenceBlock>
<move element="register-link" destination="header.links"/>
<move element="top.links" destination="customer"/>
<move element="authorization-link" destination="top.links" after="-"/>
</body>
</page>
~~~
現在客戶的聯系看起來是這樣的:

最后觸摸添加樣式:

- 前端開發
- 前端開發人員指南
- 介紹
- 主題模塊路徑規則符號
- 主題Themes
- 概括
- 創建主題
- magento主題結構
- 應用和配置管理主題
- 配置圖片屬性主題
- 主題繼承
- 定位模板,布局和樣式
- 布局layout
- 布局說明
- 布局文件類型
- 擴展繼承布局
- 覆蓋布局
- 公共布局任務定制
- 自定義布局圖
- 模板Templates
- 模板定制演練
- 模板的基本概念
- 定制的模板插圖
- 定制電子郵件模板
- 模板XSS安全
- 層疊樣式表(css)
- 載入css
- magento繼承修改模板.phtml
- 只修改phtml文字內容
- 在magento的block之前加內容
- PHP開發
- PHP開發人員指南
- 開發路線圖
- composer簡介
- 常見術語表
- 準備(開發快速啟動)
- 組件類型和版本
- 有關組件文件結構
- 路線圖制定和包裝組件
- 建立
- composer.json文件
- 創建組件文件結構
- 定義你的配置文件
- 注冊您的組件
- URN架構驗證
- 命名部件
- 組件加載順序
- 啟用或禁用組件
- package包
- 打包組件
- 更新
- 驗證
- 測試你的組件
- 加入CLI命令
- 命令命名指南
- 如何添加CLI命令
- 組件開發
- 服務合同
- 公共接口和API
- 服務合約設計模式
- 依賴注入
- 實例化對象與工廠
- 代理
- 代碼生成
- EAV和擴展屬性
- Magento的插件
- 路由
- 索引
- 配置服務網絡的API
- 向后兼容性
- 消息隊列
- 在開發過程中清除目錄
- magento設置
- magento開發模式設置
- magento安裝中文語言包
- 創建一個新的block
- magento后臺操作
- 調試-頁面phtml所在的目錄
- magento添加分類
- 添加屬性
- 屬性組
- 組合商品
- 配置商品
- 虛擬商品
- 捆綁商品
- 可下載商品
- 商品促銷設置
- CMS頁面設置
- block使用
- connect使用
- 多店鋪
- 聯系我們
- paypal設置
- 物流運費
- 網站地圖
- 訂單處理
- 賬號管理
- 網站貨幣設置
- google分析
- 頁面默認設置
- Magento技巧積累
- 常用技巧
- magento2更改商品圖片在網站中不同位置的大小
- magento的view里面的default.xml