Sorry, no results found - try a different search..

  • Posts: 52
  • Thank you received: 2
10 years 3 months ago #166231

Hi,

I've included some PHP to echo the following text:"Sorry, no results found - try a different search selection" when the filter does not show any search results.

The code I have input in the Display>Views>product>listing_div is as follows:
if(empty($this->rows)){
echo '<p>Sorry, no results found - try a different search selection</p>';
}

The problem I'm having, is that the message also shows up on the pages where the filter is not inserted.
Example: www.elevateyoursole.co.uk/mens

Is there anything I can do to stop it from showing up on the pages where the filter is not active?

Thanks in advance :)

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
10 years 3 months ago #166232

Hi,

You should actually add the check in the "listing" view file of product in order to be able to add a second condition on the variable $htmlFilter in order to only display your message if $htmlFilter is not empty (meaning only on pages where the filters are displaying at the top of the products listing).

Please Log in or Create an account to join the conversation.

  • Posts: 52
  • Thank you received: 2
10 years 3 months ago #166298

Hi Nicolas,

I've tried:

<?php
if (isset($htmlFilter) && empty($htmlFilter->rows)) {
echo '<p>Sorry, no results found - try a different search selection</p>';
}
?>

and other:
<?php
if( isset($htmlFilter->rows) && empty($htmlFilter->rows) ) {
echo '<p>Sorry, no results found - try a different search selection</p>';
}
?>

and other:
<?php
if(empty($htmlFilter->rows) && isset($htmlFilter)){
echo '<p>Sorry, no results found - try a different search selection</p>';
}
?>

But it's still not working. I'm pulling my hair out about it :-(

What am I doing wrong?

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
10 years 3 months ago #166305

Try like that:
if(empty($this->rows) && !empty($htmlFilter)){
echo '<p>Sorry, no results found - try a different search selection</p>';
}
Also, you can't add your code at the beginning of the file. I think that the best is to add it just before the line:
} else if(!empty($this->rows) && !empty($this->categories)) {

The following user(s) said Thank You: Lexnia

Please Log in or Create an account to join the conversation.

  • Posts: 52
  • Thank you received: 2
10 years 3 months ago #166587

PERFECT!!! Thank you :-)

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 9 months ago #191208

nicolas wrote: ... in order to only display your message if $htmlFilter is not empty (meaning only on pages where the filters are displaying at the top of the products listing).


Hi,

Any chance to produce a message with a filter module if the search ends with no result?

Thanks!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 9 months ago #191559

Hi,

That can be done really easily. You can see the code for that in the file "listing" of the view "product" if you have a recent version of Hikashop and your template doesn't have an override from an old version of HikaShop :

}elseif(( !$this->module || JRequest::getVar('hikashop_front_end_main',0) ) && (@$_GET['ctrl']=='product' || @$_GET['view']=='product') && (@$_GET['task']=='listing' || @$_GET['layout']=='listing') && !empty($this->filters) && count($this->filters)){
		echo JText::_('HIKASHOP_NO_RESULT');
	}
And in the translation file of HikaShop, you have this line:
HIKASHOP_NO_RESULT=" "
So just use a translation override on it to set the message you want.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 9 months ago #191569

Thanks Nicolas,

Indeed, this looked VERY simple... one of the well hidden features, haha. Might be a bit late in the game, but I suggest you put something other than only a space in between the quotes for that namekey in the default language files. ;)

So, I did the language override, but still no display of the message when no filter search result is found.

Conditions:
HS 2.3.5, no view override for "product / listing".
Filter is a text filter, works fine with displaying results and all.
First I thought there's a problem due to the filter module being positioned in a Custom HTML module through a tag from NoNumber's "Modules Anywhere", but even if I place it in a regular position by itself, the message won't show.
The HTML of neither module nor component area is showing any hint of the message. For the fun of it, I even wrapped it inside a div in listing.php to see if at least the tags would show up, but nothing... :(

Am I overlooking something else?


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 9 years 9 months ago by lousyfool.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
9 years 9 months ago #191624

Hi,

It is not related to the filter module or to the position of the filter module.
The text is displayed by the product listing menu if the menu does not display any product and the filters are not empty.

So, it would be interesting to know more about your product listing.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 9 months ago #191638

Hi Jerome,

Let me give you as much information as seems somehow relevant to me:

The product listing menu item (ID 2621) is very basic as it lists all products in the shop. It's hidden, and serving only as menu item which all modules below category listings point to, and for the filter - this way providing a consistent URL.

All works perfectly fine (except for that darn "no results" message...):
The menu item's URL is "mydomain.xyz/shop", and if I enter the URL in the browser, it does indeed list all products.
As intended, all URLs of products are accordingly "mydomain.xyz/shop/........", including the ones found by the filter.
The filter module is also pointing to this menu item (2621), and as stated, it searches and finds correctly if the search term is good, or it shows no results if indeed nothing can be found. In any case, it returns the URL "mydomain.xyz/shop/product/listing", though - as mentioned - product links from search results are as expected "mydomain.xyz/shop/........".

Just for the jux of it, I just switched to Protostar, and also tried the language override on an almost identical site under J!2.5.28, HS2.3.5 and yet another template... same thing: all works fine, except no "no result" message anywhere.

I'm attaching screenshots, too:
1. The product listing config: Very basic with lots of "inherit" due to all default settings found to be good. Note that the associated category "Home" is the equivalent of the default "Product category" - the client had only renamed it. (Update: I reset it to "Product category", but no help.)
2. The filter settings: Again, working fine.
3. The filter module config: Note the menu ID, which happens to be the listing we're talking.

Please trust me: The "listing" view is untouched. Yes, I do know how to do language overrides - all others work, and no funky stuff in this one, only boring text in between the double-quotes. Of course, no cache anywhere near the site when trying.

Hope this info is sufficient. If you need anything else, like screenshots of the default config for the listing or so, please give me a brief hint.

Thanks again!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Attachments:
Last edit: 9 years 9 months ago by lousyfool. Reason: Update on "Product category" "Home"

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 9 months ago #191667

Hi,

I did a test on my end and it worked fine:
default products listing menu item of HikaShop with just the display filter option turned off: take.ms/52Kpd
a simple text filter : take.ms/XBVSR
the filter module with the filter selected and the id of the menu item entered: take.ms/0Bavq
a simple translation override as I explained: take.ms/LflHc
search a text that doesn't exist and I get the "no result" message: take.ms/FmfeX

So if you did the same and it doesn't work, the only things I can think of are:
- error in the translation override file
- an override of the view without the code to display the message

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 9 months ago #191904

Hey Guys,

And thanks to Nicolas for test-driving the thing for me.

I got it to work.

Though, the "solution" leaves me baffled. Maybe you too, maybe there's a weirdly simple explanation for it, maybe I'm up for a surprise still later?

First, and just for the record, I did go through the routine - again, juuuuust in case:
Using the name key elsewhere: ok, the translation works.
File comparison of existing listing.php with a freshly downloaded one: ok, it's clean.
Double and triple-checking the output, above the fold and HTML: nothing.
Wrapping the JText in divs: not even those pop up. Of course not.
It's a J!2.5 -> 3.3.6 migration... scanning the database for filter-related irregularities: nothing that I could find.

Most hair torn out by then and close to giving up, I thought I should try getting rid of the whole condition before the echo. The message might be wrongly there all the time then, but just to see it at least once...
So, replacing the lines Nicolas quoted here 5 posts above with only:

}else {
    echo JText::_('HIKASHOP_NO_RESULT');
    }

And... IT WORKS!!! :woohoo:

Lo and behold, the "no results" message does show up if there are no results, and does not show up if there is any result. Duh.

Now, is this black magic? Or did you waste a minute or two when you wrote the condition? ;)


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 9 years 9 months ago by lousyfool. Reason: Thanks (almost forgot!), and some quotes

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 9 months ago #191925

No that condition is necessary so that you don't get the error message on categories listing menu items where there are no products displayed by the associated module on the category listing (only when you click on a subcategory).
It might not be necessary for you based on how you configured your menu items, but that condition is necessary by default in HikaShop for it to work properly in all cases.

But if that works for you like that, then great.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
9 years 9 months ago #192052

Thanks for the warning, Nicolas.

I don't get the "no results" message in category listings, because parent categories are set to show "All sub elements", and all 'lowest level' subcategories do contain products - so, there's no listing without products, except for an empty filter search. So, yes, it works.

One could then argue if a "No products found" or similar message sort of emphasising "products" makes good sense in category listings returning no products, too, but that might depend on the case. (So, no need for me to discuss this further.)

And then the fact of the intended condition working for you and maybe everyone else but not for me still remains to be a mystery, but since the workaround is cool, we can consider the case closed for the time being.

Thanks again!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
9 years 6 months ago #200630

Hi Nicolas

Hikashop Business 2.3.4
No product view overrides.
Filter is Single dropdown on Custom fields
Filter is embedded in a module and shows on all product pages.

I have set up the language override as suggested to achieve the message on 'no records selected' from the filter.

This works fine when selection criteria are selected with no related product but only when the menu item 'Product Listing' is selected.
When the Filter button is used the overide message does not appear.

The other solution of using the product listing overide does not work for me as the filter has been removed from the top of the product listing and is in the module.

Any help would be greatly appreciated.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #201058

Hi,

Do you have set the correct menu id for the "menu" option in the HikaShop filter module settings ?
The id must be the id of a product listing menu.

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
9 years 6 months ago #201095

Yes the same menu ID has been assigned as the menu item for Products listing menu.

After the filter button is pressed no message appears, but then when the Product listing menu is selected the message appears.

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
9 years 6 months ago #201140

Hi,

I see that you're using an old version of HikaShop. Maybe it comes from that.
Edit the file "listing" of the view "product" for your frontend template via the menu Display>Views.
There you should have that code:

elseif(( !$this->module || JRequest::getVar('hikashop_front_end_main',0) ) && (@$_GET['ctrl']=='product' || @$_GET['view']=='product') && (@$_GET['task']=='listing' || @$_GET['layout']=='listing') && !empty($this->filters) && count($this->filters)){
		echo JText::_('HIKASHOP_NO_RESULT');
	}
if you don't see it, it means that you're using an old version of the view file for the listing of products where that "no result" message was not possible.
You would have to either update Hikashop or remove the override that you have on that view file so that it uses the new code we added to support that capability.

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
9 years 6 months ago #201225

That code does exist in the listing file.

I have no override in this file, the only override is in the Language override.

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
9 years 6 months ago #201232

Hikashop upgraded to version 2.4.0 and still have the problem.

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum