Jump to content

[SOLVED] Search Box "Array" not keyword


Recommended Posts

Hi there,

 

I am using prestashop 1.4 and the search box is all good (returning expected results) but above the results it says 'Search "ARRAY"' and not as it should say 'Search "chair" ' (chair being what I have typed in the search box and asked it to search for!)

Can anybody help?

Many Thanks

Link to comment
Share on other sites

open search.tpl file located in your theme directory

 

you should have there similar code:
 

<h1 {if isset($instantSearch) && $instantSearch}id="instant_search_results"{/if}>
{l s='Search'} {if $nbProducts > 0}"{if isset($search_query) && $search_query}{$search_query|escape:'htmlall':'UTF-8'}{elseif $search_tag}{$search_tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if}
{if isset($instantSearch) && $instantSearch}<a href="#" class="close">{l s='Return to the previous page'}</a>{/if}
</h1>

can you compare your code with this one?

Link to comment
Share on other sites

I have a confession to make - I have made a mistake!! (sorry)
The code in my search.tpl file is NOT the same at all as yours (I had been looking at another file I had downloaded earlier when trying to solve)
Here is the correct code on my server in the search.tpl file:

{capture name=path}{l s='Search'}{/capture}
{include file=$tpl_dir./breadcrumb.tpl}

<h2>{l s='Search'} {if $nbProducts > 0}"{if $query}{$query|escape:'htmlall':'UTF-8'}{elseif $tag}{$tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if}</h2>

{include file=$tpl_dir./errors.tpl}

{if !$nbProducts}
	<p class="warning">
		{if $query}
			{l s='No results found for your search'} "{$query|escape:'htmlall':'UTF-8'}"
		{elseif $tag}
			{l s='No results found for your search'} "{$tag|escape:'htmlall':'UTF-8'}"
		{else}
			{l s='Please type a search keyword'}
		{/if}
	</p>
{else}
	<p class="search_page">{$nbProducts|intval} {if $nbProducts == 1}{l s='result has been found.'}{else}{l s='results have been found.'}{/if}</p>
	{include file=$tpl_dir./product-sort.tpl}
	{include file=$tpl_dir./product-list.tpl products=$products}
	{include file=$tpl_dir./pagination.tpl}
{/if}
Link to comment
Share on other sites

ohh it looks really strange, like problem with search controller (passing wrong variables to smarty)

 

you can remove code that you added. here is a little workaround:

 

instead this:

<h2>{l s='Search'} {if $nbProducts > 0}"{if $query}{$query|escape:'htmlall':'UTF-8'}{elseif $tag}{$tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if}</h2>

use this code:

<h2>{l s='Search'}
 
{if $nbProducts > 0}
{if $smarty.get.search_query}
{$smarty.get.search_query|escape:'htmlall':'UTF-8'}
{/if}
{/if}
</h2>
  • Like 2
Link to comment
Share on other sites

That is great ! It works. I cant thank you enough, you are a real expert!

I now get the correct search tag displaying before the results. :)  :)  :)

 

 

 

ohh it looks really strange, like problem with search controller (passing wrong variables to smarty)

 

you can remove code that you added. here is a little workaround:

 

instead this:

<h2>{l s='Search'} {if $nbProducts > 0}"{if $query}{$query|escape:'htmlall':'UTF-8'}{elseif $tag}{$tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if}</h2>

use this code:

<h2>{l s='Search'}
 
{if $nbProducts > 0}
{if $smarty.get.search_query}
{$smarty.get.search_query|escape:'htmlall':'UTF-8'}
{/if}
{/if}
</h2>
Link to comment
Share on other sites

  • 2 weeks later...

 

ohh it looks really strange, like problem with search controller (passing wrong variables to smarty)

 

you can remove code that you added. here is a little workaround:

 

instead this:

<h2>{l s='Search'} {if $nbProducts > 0}"{if $query}{$query|escape:'htmlall':'UTF-8'}{elseif $tag}{$tag|escape:'htmlall':'UTF-8'}{elseif $ref}{$ref|escape:'htmlall':'UTF-8'}{/if}"{/if}</h2>

use this code:

<h2>{l s='Search'}
 
{if $nbProducts > 0}
{if $smarty.get.search_query}
{$smarty.get.search_query|escape:'htmlall':'UTF-8'}
{/if}
{/if}
</h2>

 

Thank you so much for this code, Vekia. My problem was that I got the search query result I had typed in the search box, but with no diacritics in my language. I used your code and now I'm getting perfect results including all special characters. Thank you, again. Jana

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...