Magento – Magento topSearch not showing

catalogsearchmagento-1.9rwd-theme

I'm trying to display the (quick) search in the navigation menu.
Here is what I have so far:

catalogsearch.xml

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

top_nav.phtml

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

But the search bar isn't showing.

  • I've refreshed the caches
  • It isn't hidden by CSS, it isn't even showing in the inspector
  • I'm working from the right template

What am I doing wrong?

Best Answer

Just change $this->getChildHtml('topSearch') to $this->getBlockHtml('topSearch')

OR:

As you call this searchbox as child block of in top_nav.phtml but you have call in header child block in xml file.So it not coming

So you need to change reference parent block of search from header to top_nav.phtml file block.

Just like concept:

top_nav.phtml block name is topNav

guess that

<block type="...." name="topNav" template="..../top_nav.phtml ....

then

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

should be

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