Jump to content

Подскажите как сделать


Recommended Posts

Привет
Подскажите плиз как сделать

в поиске нужно удалять дифисы чтобы одинаково искалось:
ABC00000000
ABC-00000000

Пошел по самому простому пути: 
в шаблоне сделал замену:

<form id="searchbox" method="get" action="{$link->getPageLink('search', null, null, null, false, null, true)|escape:'html':'UTF-8'}" >
     {$search_query = str_replace("-","",$search_query)}
        <input type="hidden" name="controller" value="search" />
        <input type="hidden" name="orderby" value="position" />
        <input type="hidden" name="orderway" value="desc" />
        <input class="search_query form-control" type="text" id="search_query_top" name="search_query" placeholder="{l s='Search' mod='blocksearch'}" value="{$search_query|escape:'htmlall':'UTF-8'|stripslashes}" />
        <button type="submit" name="submit_search" class="btn btn-default button-search">
            <span>{l s='Search' mod='blocksearch'}</span>
        </button>
    </form>
</div>

замена:

{$search_query = str_replace("-","",$search_query)}

Тире удаляется но поиск производится все равно с тире

Сам модуль откопал, можно тут как то применить поиск и замену тире?? 

public function hookTop($params)
    {
        $key = $this->getCacheId('blocksearch-top'.((!isset($params['hook_mobile']) || !$params['hook_mobile']) ? '' : '-hook_mobile'));
        if (Tools::getValue('search_query') || !$this->isCached('blocksearch-top.tpl', $key))
        {
            $this->calculHookCommon($params);
            $this->smarty->assign(array(
                'blocksearch_type' => 'top',
                'search_query' => (string)Tools::getValue('search_query')
                )
            );
        }
        Media::addJsDef(array('blocksearch_type' => 'top'));
        return $this->display(__FILE__, 'blocksearch-top.tpl', Tools::getValue('search_query') ? null : $key);
    }

    public function hookDisplayNav($params)
    {
        return $this->hookTop($params);
    }

    public function hookDisplaySearch($params)
    {
        return $this->hookRightColumn($params);
    }

    private function calculHookCommon($params)
    {
        $this->smarty->assign(array(
            'ENT_QUOTES' =>        ENT_QUOTES,
            'search_ssl' =>        Tools::usingSecureMode(),
            'ajaxsearch' =>        Configuration::get('PS_SEARCH_AJAX'),
            'instantsearch' =>    Configuration::get('PS_INSTANT_SEARCH'),
            'self' =>            dirname(__FILE__),
        ));

        return true;
    }
}
Edited by nekit44 (see edit history)
Link to comment
Share on other sites

$key = $this->getCacheId('blocksearch-top'.((!isset($params['hook_mobile']) || !$params['hook_mobile']) ? '' : '-hook_mobile'));
		if (Tools::getValue('search_query') || !$this->isCached('blocksearch-top.tpl', $key))
		{
			$this->calculHookCommon($params);
			$this->smarty->assign(array(
				'blocksearch_type' => 'top',
				'search_query' => str_replace("-","",(string)Tools::getValue('search_query'))
				)
			);
		}
		Media::addJsDef(array('blocksearch_type' => 'top'));
		return $this->display(__FILE__, 'blocksearch-top.tpl', Tools::getValue('search_query') ? null : $key);

'search_query' => str_replace("-","",(string)Tools::getValue('search_query'))

 

Дописал вроде заработало, интересно я прав или нет

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...