2012-09-11 173 views
-1

我正嘗試從搜索欄下方的頁腳鏈接移動magentos高級搜索鏈接。magento高級搜索

我知道,鏈接的起源是在佈局/ catalogsearch.xml下 參考名稱=「footer_links」和(「footer_links」)出現在因爲直到最底層的頁腳中footer.phtml

,我知道搜索欄起源於template/catalogsearch/form.mini.phtml,並通過catalogsearch.xml在參考名稱=「top.menu」下出現

有關如何在此處繼續的任何想法?

+0

標題非常誤導 –

回答

0

爲了這個工作,你必須:

1)更新您的應用程序/設計/前端/ [yourtheme] /default/layout/local.xml文件

2)調用新塊在app/design/frontend/[yourtheme] /default/template/page/html/header.phtml - 這是必需的,因爲header.phtml不是自動呈現其嵌套塊的「core/text_list」塊類型。因此,我們必須明確地告訴Magento的渲染這些子塊

你的應用程序/設計/前端/ [yourtheme] /default/layout/local.xml應該包含這樣的:

<?xml version="1.0"?> 
<layout version="0.1.0"> 

    <default> 

     <reference name="header"> 

      <!-- Insert cms links. No need to use <action method="insert"> as this block is not used elsewhere in layout --> 
      <block type="cms/block" name="top_links_cms" as="top_links_cms" before="top_links_other"> 
       <action method="setBlockId"><block_id>footer_links</block_id></action> 
      </block> 

      <!-- Insert former footer links. --> 
      <action method="insert"> 
       <!-- We must keep block name "footer_links" as it is used as a reference for adding links by other modules --> 
       <blockName>footer_links</blockName> 
       <!-- Name of the block we want to have as sibling (in order to get its position and place our block after it. See next node <after> --> 
       <siblingName>topSearch</siblingName> 
       <!-- $after param from Mage_Core_Block_Abstract::insert() is a boolean type, so its value in the XML node is [empty], 0 or 1 --> 
       <after>1</after> 
       <alias>top_links_other</alias> 
      </action> 
     </reference> 

     <reference name="footer"> 
      <action method="unsetChild"><name>footer_links</name></action> 
      <action method="unsetChild"><name>cms_footer_links</name></action> 
     </reference> 

    </default> 

</layout> 

這是一個更新的標題。 PHTML你可以從你的應用程序/設計/前端/ [yourtheme] /default/template/page/html/header.phtml文件中獲取靈感:

<div class="header-container"> 
    <div class="header"> 
     <?php if ($this->getIsHomePage()):?> 
     <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1> 
     <?php else:?> 
     <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a> 
     <?php endif?> 
     <div class="quick-access"> 
      <?php echo $this->getChildHtml('topSearch') ?> 



      <?php 
      /** 
      * Add other top links (footer and cms links) 
      */ 
      ?> 
      <?php echo $this->getChildHtml('top_links_cms') ?> 
      <?php echo $this->getChildHtml('top_links_other') ?> 



      <p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p> 
      <?php echo $this->getChildHtml('topLinks') ?> 
      <?php echo $this->getChildHtml('store_language') ?> 
     </div> 
     <?php echo $this->getChildHtml('topContainer'); ?> 
    </div> 
</div> 
<?php echo $this->getChildHtml('topMenu') ?> 
+1

謝謝你的建設性批評。 – philwinkle

3

感謝你的快速解答! 但它不完全是我正在尋找的,因爲它會顯示搜索欄下方的整個頁腳鏈接塊。 儘管如此,非常感謝您向我展示您使用的方法!

不管怎麼說,我想通了,我自己的解決方案:

我修改catalogsearch.xml:

<default> 
    <reference name="top.menu"> 
     <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/> 
    </reference> 


<!-- add a new reference to top.search including my new adv.search block --> 
    <reference name="top.search"> 
     <block type="page/template_links" name="adv.search" as="adv.search" > 

      <action method="addLink" translate="label title" module="catalogsearch"> 
       <label>Advanced Search</label> 
       <url helper="catalogsearch/getAdvancedSearchUrl" /> 
       <title>Advanced Search</title> 
      </action>  

     </block> 
    </reference> 
<!-- the reference to the footer i commented out as its not longer needed; it includes advanced search and popular search terms--> 
</default> 

在form.mini.phtml我添加了一個新的div調用adv.search:

</script> 

<div class="adv-search"> <?php echo $this->getChildHtml('adv.search') ?> </div> 

</div> 

而在去年,在Styles.css中,我添加了一些代碼,以控制好該div的長相:

.adv-search {width:100px; height:15px; margin-top:24px; margin-left: 120px;} 
.adv-search a { color:#fff; font-weight:bold; } 

任何額外的建議是多餘的歡迎

乾杯!