Question

i am try to call advanced search in custom.phtml

<?php echo $this->getLayout()->createBlock('catalogsearch/advanced_form')->setTemplate('catalogsearch/advanced/form.phtml')->toHtml() ?>

like this when i try to search it goes to

http://127.0.0.1/magento-19/index.php/cms/index/result/?name=saf&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&type_cartridge=&merk=&eancode=

if i mannually add catalogsearch/advanced instead cms/index it shows me fine.

Pst: custom.phtml directly shows through cms/page

<p>{{block type="categorydrop/navigation" template="categorydrop/custom.phtml"}}</p>

so, how can i use advanced search in custom.phtml ?

also my default search is not working? i want to work as autosearch but its not show me result?

i use <?php echo $this->getChildHtml(‘topSearch’) ?> this in custom.phtml for use default search its not show me.

Thanks in advanced...

Was it helpful?

Solution

You get that strange url because of the method getSearchPostUrl in the advanced search form class. It looks like this:

public function getSearchPostUrl()
{
    return $this->getUrl('*/*/result');
}

This means that the url where the search form will be sent is {current_module}/{current_controller}/result.
You have to options here.

  1. Clone catalogsearch/advanced/form.phtml into an other template file, use that for rendering the block and change inside it:

    <form action="<?php echo $this->getSearchPostUrl() ?>" method="get" id="form-validate"> to <form action="<?php echo $this->getUrl('catalogsearch/advanced/result') ?>" method="get" id="form-validate">

  2. Create a new block class that extends Mage_CatalogSearch_Block_Advanced_Form, use that for your homepage, and change the getSearchPostUrl to return $this->getUrl('catalogsearch/advanced/result').

I would go with option 1. Less work.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top