1

I would like to move the search facility from the header.phtml, to the category view page. Looking at other posts I have created the following entry in my local.xml file:

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

And in app\design\frontend\default{Theme Name}\template\catalog\category\view.phtml

I have the following:

  <?php  echo $this->getChildHtml('topSearch') ?>

Am I doing something wrong?

EDIT:

Full local.xml file:

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

  <remove name="checkout.cart.coupon"></remove>
  <remove name="checkout.cart.shipping"></remove>

</default>

<catalog_category_default>
 <reference name="header">
     <action method="unsetChild"><name>top.search</name></action>
 </reference>
 <reference name="category.products">
     <action method="insert"><block>top.search</block></action>
 </reference>
</catalog_category_default>
<catalog_category_layered>
  <reference name="header">
     <action method="unsetChild"><name>top.search</name></action>
 </reference>
 <reference name="category.products">
     <action method="insert"><block>top.search</block></action>
 </reference>
 </catalog_category_layered>

 <catalogsearch_result_index translate="label">
  <label>Quick Search Form</label>
  <reference name="root">
      <action method="setTemplate"><template>page/1column.phtml</template></action>
  </reference>
 </catalogsearch_result_index>
</layout> 
2

You will need to add the block to the correct parent. You mentioned the template catalog/category/view.phtml so working from this information you will need the handles catalog_category_default and catalog_category_layered. The parent block has the name category.products in both cases.

<catalog_category_default>
    <reference name="header">
        <action method="unsetChild"><name>top.search</name></action>
    </reference>
    <reference name="category.products">
        <action method="insert"><block>top.search</block></action>
    </reference>
</catalog_category_default>
<catalog_category_layered>
    <reference name="header">
        <action method="unsetChild"><name>top.search</name></action>
    </reference>
    <reference name="category.products">
        <action method="insert"><block>top.search</block></action>
    </reference>
</catalog_category_layered>

What this will do is remove the search from the header and add it to the category products block as a child, you can then call getChildHtml in your template.

| improve this answer | |
  • Just tried your suggestion it don't work either. Any other suggestions? – user9252 Sep 9 '14 at 14:39
  • @user9252 what actually happened? Did it just do nothing? – David Manners Sep 9 '14 at 14:42
  • it did nothing. – user9252 Sep 9 '14 at 14:46
1

I know this question is very old, but I gonna post my awnser hopping it can help others with this same problem

In my case, I needed another search form on my footer so I opened

app/desing/frontend/base/default/layout/catalogsearch.xml

and copied:

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

to: app/desing/frontend/my-theme/my-theme/layout/local.xml inside the default tags

<reference name="header">
        <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
    </reference>
</default><!-- just to give a idea of the position of where you should paste this code -->

and then I changed it to:

<reference name="footer">
        <block type="core/template" name="footer.search" as="footerSearch" template="catalogsearch/form.mini.phtml"/>
    </reference>
</default>

then in my footer file I called:

<?php echo $this->getChildHtml('footerSearch') ?>

basically you have to tell where your theme needs to get the 'footerSearch' using the local xml, then you can call it thought php.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.