我是Magento的新手。我已經在Magento下載了一個主題,並嘗試更改頂部鏈接。我無法跟蹤文件。如何更改Magento主題中的主要鏈接。magento頂部鏈接更改
回答
你必須要像福爾摩斯一點點。 由於您可以在主題的佈局文件page.xml中找到塊,因此會生成頂級鏈接。然後搜索標題塊中的塊名稱「topLinks」(在默認主題中,它是名稱),您會發現<block type="page/template_links" name="top.links" as="topLinks"/>
。該塊topLinks由塊類Mage_Page_Block_Template_Links生成。這個塊中的重要方法是public function addLink(...)
,這意味着您將不得不搜索xml佈局中的以下元素/標記<action method='addLink'>...</action>
。
爲客戶模塊的一個例子,在佈局文件夾中的文件customer.xml:
<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>
你應該找到它使用這種方法不止一個XML元素。 注意,addLink方法也可以通過編程方式調用(到PHP代碼中),而不僅僅是在佈局文件中調用。
希望它可以幫助
你需要修改兩個文件...
app/design/frontend/default/default/layout/checkout.xml
app/design/frontend/default/default/layout/customer.xml
你會在這些鏈接被添加爲name="top.links"
這些文件看 - 只需要使用評論標籤將其發表評論即可
希望這會幫助你。
感謝
我只是評論他們,但仍然顯示在頂部的頂部鏈接。我不知道爲什麼以及如何編輯現有鏈接?我是magento的新手。所以請提供一些詳細的幫助。謝謝 – designersvsoft 2012-03-09 04:38:13
如果你沒有清理緩存,那麼它仍然會顯示。所以從var-> cache文件夾中刪除緩存。並且瀏覽器也希望它現在能夠工作 – 2012-03-09 14:18:42
這是很難回答你的問題的一些主題傾向於移動文件和做古怪的事情。嘗試切換模板提示,這將向您顯示正在渲染的模板在文件系統中的位置。
http://help.sweettoothrewards.com/article/434-how-do-i-turn-on-template-path-hints
「佈局XML」可能會成爲「Magento的道路」將鏈接插入到該塊,並引用將top.links塊。
粗略的谷歌搜索產生了一個有點過時,但仍然相關的文章,做你想做的事情。
http://excellencemagentoblog.com/blog/2011/09/07/magento-add-top-links-in-magento/
要小心你是如何擴展和修改你的主題和基礎Magento的主題。您最終可能會爲下一位開發人員創建大量額外工作。
我會鼓勵你在進行很多修改之前先研究一下Magento主題回滾系統。
無需更改任何源代碼。
步驟1:登錄管理面板。
步驟2:轉到目錄>從頂部導航管理類別
步驟3:點擊「添加子類別」
步驟4:轉到「顯示設置」標籤,設置「顯示模式」選擇(創建CMS>靜態塊下的靜態塊)
步驟5:用所需字段保存類別。
使用模板路徑提示,您可以輕鬆找到您的模板路徑文件。 登錄到管理員潘內爾和下
- 系統 - >配置
- 更改(您想看到模板路徑或任何商店視圖)
- 在高級「配置範圍」爲「默認存儲視圖」在左邊的菜單中點擊開發
- 單擊「調試」,以展開該部分
- 更改「模板路徑提示」爲「是」
- 點擊保存配置
現在,您只需刷新商店的前端,即可查看以紅色顯示的模板路徑。這個模板路徑提示會讓你知道哪個塊負責顯示特定的部分。
當您完成編輯時,不要忘記隱藏模板路徑。
啓用從Magento管理面板開發模式
得到系統 - >從管理
配置然後從左側欄最後的菜單中選擇您的當前配置範圍: 和高級 - >開發技術>調試 - >模板路徑提示爲yes
,則跳轉到前端,會告訴你所有模板路徑 遵守給出的模板路徑和改變任何你想要的
並且不要忘記關閉開發者模式
請在主題文件夾下創建local.xml,然後嘗試通過url鍵刪除頂部鏈接。請將下面的代碼粘貼到local.xml中。
<default>
<reference name="top.links">
<action method="removeLinkByUrl">
<url helper="checkout/url/getCartUrl" />
</action>
</reference>
</default>
謝謝。
頂部鏈接主要來自.phtml文件,但我們建議您最好的方式來刪除這個.XML文件。在XML文件中搜索「top.links」文本&此文本在引用名稱上分配,以便您可以從中刪除所有鏈接。XML文件(配置文件)
例子:
<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>
第一步:登錄到Magento管理
第二步:進入目錄
第三步:去管理類別
第四步:他們是主題的頂部鏈接,然後你可以編輯該鏈接
app\design\frontend\{namespace}\{yourtheme}\template\page
在這裏你可以找到你header.phtml,footer.phtml和車身佈局
頂部鏈接包括:登錄/註銷,我的帳戶,我的收藏,我的車和結算環節。 頂部鏈接和常規靜態鏈接之間最重要的差異之一是,當您將產品添加到購物車或添加到您的願望清單時,頂部鏈接會自動記錄添加的產品。 標題中默認Magento主題中頂部鏈接的示例。 Magento中頂部鏈接的使用 在Magento中編輯標題鏈接非常簡單。首先,我們必須打電話給該塊。
<?php echo $this->getChildHtml('topLinks'); ?>
模板模板
/頁/ HTML/header.phtml,但創造了page.xml
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="core/text_list" name="top.menu" as="topMenu"/>
</block>
現在,我們需要使用命令將鏈接添加到該塊:
<action method="addLink" translate="label title" >...</action>
我們讓它在以下XML文件:
登錄/註銷,我的賬戶 - customer.xml
我的購物車和Checko UT - checkout.xml
我的收藏 - wishlist.xml
應該由命令指出的是鏈接到我的車電話:
<action method="addCartLink"></action>
<action method="addCheckoutLink"></action>
如果你想改變Magento的排名靠前,你需要知道所有頂部鏈接都基於位於此處的模板:page/template/links.phtml。在這裏你可以添加額外的類或提交所需的更改。
通常人們想要使用單獨的鏈接。例如登錄/註銷和我的帳戶應該在左側,我的願望清單,我的購物車和結帳在右側。
喜歡的東西在下面的例子中 這是很容易做到:
打開page.xml並創建另一個塊存在,幾乎等同於「排名靠前」,但名稱爲「topLinksLeft」;
<block type="page/html_header" name="header" as="header">
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu"/>
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/template_links" name="top.links.left" as="topLinksLeft"/>
</block>
在模板的模板/頁/ HTML /頭。用命令的幫助PHTML:
<?php echo $this->getChildHtml('topLinksLeft'); ?>
我們可以調用我們擋在了正確的位置
<div>
<h1 id="logo" title="<?php echo $this->getLogoAlt() ?>" style="background-image:url(<?php echo $this->getLogoSrc() ?>);"><a href="<?php echo $this->getUrl('') ?>"><?php echo $this->getLogoAlt() ?></a></h1>
<div><?php echo $this->getChildHtml('topLinksLeft') ?></div>
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('topMenu') ?>
</div>
當你做到了這一點,開放customer.xml我們必須改變塊的名稱負責登錄/註銷,我的帳戶。我們從「top.links.left」「top.links」作爲例子更名:
<customer_logged_in>
<reference name="top.links.left">
<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>
<reference name="top.links.left">
<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>
我們也可以指定其他模板左側(在某些情況下相當有用)對於鏈接我們只需要複製模板「page/template/links.phtml」並將其稱爲links_left.phtml。所以現在我們有兩個模板「links.phtml」用於右側,「links_left.phtml」用於左側。現在我們需要做的只是連接它。對於連接,我們使用block«topLinksLeft»page.xml並將其更改爲links_left.phtml。
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/template_links" name="top.links.left" as="topLinksLeft" template="page/template/links_left.phtml"/>
</block>
現在,您可以在左側和右側應用不同的樣式和HTML。
哇,幾乎忘記了通常位於「登錄/註銷」按鈕附近的「註冊」按鈕。不用擔心。正如您已經猜到,我們從客戶開始。在這裏我們做下一個,如果我們要添加「註冊」按鈕頂端鏈接XML文件:
<customer_logged_out>
<reference name="top.links">
<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="addLink" translate="label title" module="customer">
<label>register</label>
<url helper="customer/getRegisterUrl"/>
<title>register</title>
<prepare/>
<urlParams/>
<position>10</position>
</action>
</reference>
</customer_logged_out>
所以,現在你可以改變Magento的排名靠前的:例如,從增加註冊按鈕,你的頭,甚至刪除登錄如果你想要頂級鏈接。
模板提示是你在這種情況下最好的朋友。如果您使用的是終端,請執行:
n98-magerun.phar dev:template-hints
然後選擇您當前正在使用的任何商店視圖,然後按回車。如果您對終端不太舒服,您還可以在管理員中激活它們:
System > Configuration > Developer > Template Path Hints 'YES'
注意:確保您位於右側'當前配置範圍'。如有必要,您可以在位於左上角的下拉菜單中修改此項。
然後刷新前端,複製文件路徑並搜索文件。答對了。
此代碼無需任何代碼。
進入系統 - 設置 - 常規 - 設計 - 頁眉和更改「歡迎詞」
你可以在你的模板路徑和在該文件中相應地改變: - 系統>配置>開發>模板路徑提示「 YES」 你也將獲得塊信息以及
您可以通過編輯基準名稱=‘top.links’塊 修改以下.xml文件
app/design/frontend/Your_theme/default/layout/checkout。XML
應用程序/設計/前端/ Your_theme /默認/佈局/ customer.xml
入住這下面的帖子
有關信息,請訪問以下網址: - https://www.templatemonster.com/help/magento-how-to-edit-header-links-2.html#gref
如果你刪除/更改特定的鏈接比goto特定的文件,比如你想改變我的賬戶鏈接比goto yourtheme-> layout-> customer.xml如果不存在,則轉到base-> layout-> custome r.xml
查找<reference name="top.links">
刪除/更新。
如果你想知道文件loacation,那麼你可以使用magento默認模板路徑提示功能。檢查下面給出的URL。
http://excellencemagentoblog.com/blog/2011/09/07/magento-template-path-hints-magento/
- 1. Magento - 更改現有鏈接的頂部鏈接標籤(登錄鏈接)
- 2. 無法刪除頂部鏈接Magento 1.9
- 3. magento change頂部鏈接hellowired主題
- 4. 刪除結帳頂部鏈接magento
- 5. Magento中的頂部鏈接被剝離
- 6. Magento頂部鏈接「註銷」鏈接有時不顯示
- 7. 添加自定義鏈接到頂部鏈接Magento的
- 8. Magento主頁檢出鏈接更改
- 9. Magento的 - 如何更改鏈接
- 10. 更改Iframe SRC&使用超鏈接滾動到頂部
- 11. 更改Magento的交易電子郵件logo_url外部鏈接
- 12. 如何在magento的頂部鏈接中只顯示我的帳戶鏈接?
- 13. 重命名頂部鏈接
- 14. 放置鏈接在頂部
- 15. 鏈接到頂部div
- 16. 將M博客鏈接添加到Magento頂部菜單
- 17. Magento:如何將頂部鏈接移動到導航區塊?
- 18. 如何從magento的頂部菜單中刪除「主頁」鏈接?
- 19. 如何添加鏈接到Magento的頂部菜單?
- 20. Magento將id屬性添加到頂部鏈接
- 21. Magento 1.7頂部菜單 - 子菜單鏈接生成器
- 22. 使用xml magento將鏈接添加到頂部菜單
- 23. 如何將外部鏈接添加到magento頂層菜單項
- 24. magento - 添加鏈接頁腳,但不是頂部導航菜單
- 25. 如何從Magento的頂部鏈接中刪除「Checkout」網址?
- 26. Magento頂部鏈接購物車緩存清漆
- 27. 在Magento中添加靜態鏈接到頂部導航菜單
- 28. Magento的頂部導航類別更改根
- 29. 使用local.xml更改或重新排列Magento登錄和註銷(頂部鏈接)位置
- 30. 我如何將我的願望清單文本更改爲magento 2頂部鏈接中的「願望清單」
看最後兩天的話題,你會在那裏找到同樣的問題。 – 2012-03-08 10:38:05
你想翻譯鏈接標籤嗎?改變鏈接目標?添加一個新的鏈接?刪除現有的鏈接? – Nolwennig 2016-06-10 08:25:45