我知道這個問題已經在網絡上多次提出過,但這些解決方案似乎都不適用於我。將Magento搜索移至導航欄
在模板app/design/frontend/themename/default/template/page/html/header.phtml
我有<?php echo $this->getChildHtml('headernav') ?>
在headernav.phtml
呼叫位於呼籲搜索欄<?php echo $this->getChildHtml('topSearch') ?>
的app/design/frontend/themename/default/layout/catalogsearch.xml
相關內容:
<reference name="top.menu">
<block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
</reference>
這使得搜索欄出現,但它放在o外f headernav.phtml
的內容,而不是內聯的地方。 (我查看了Chrome Dev Tools中的標記,它遠不及它應該在的位置)。我可以用CSS破解它,或者將form.mini.phtml
的內容插入到我想要的位置,但我知道這不是處理這個問題的正確方法,並且只會在稍後導致修訂。
我也曾嘗試:
<reference name="headernav">
<block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
</reference>
可以在這裏任何人都開導我,爲什麼這是不正確的模板文件中出現,我怎樣才能得到XML允許我使用這裏面一個「子-Template」的header.phtml
(如header.phtml
電話上heavernav.phtml
這就要求form.mini.phtml
)
沒有爲我工作。 – shmuli
哇@Sanketkumar比斯瓦斯你的回答救了我幾周的挫折讓我的topSearch消失與全頁緩存,因爲沒有參考名稱設置爲「catalog.topnav」 - 謝謝你太多了! :) – Joe