Jump to content

Issue with '-' in selector text?


prestoav
 Share

Recommended Posts

Hi all,

I'm having an odd issue that I think is down to the selector I'm using but I can't track down the cause!

I'm using front-end AJAX search form on a list of product adverts (pages)  where the product is made by a certain manufacturer (vendor). The manufacturer is chosen buy the person listing the adverts from a page field list of manufacturers who's parent is id=1034.

Most manufacturers are being found without an issue. The only one that's causing a problem is called 'Proj-ect" (the "-" being part of their brand name.

Here's my selector code:

$thisBrandProducts = $pages->find("template=advert,vendor.title~=$q,has_parent=1034,limit=20,created_users_id!=$susDealerList");

$susDealerList is a list of advertisers that are not currently live so pages should be excluded.

Could the "-" in the name be the issue with those pages not being returned? If so does anyone have any ideas of how I can get around this?

Thanks in advance!

Link to comment
Share on other sites

5 hours ago, dragan said:

Did you try wrapping the keyword with `backticks` ? Or use %= instead of ~= ?

Thanks dragan, the "%" cures this issue but introduces another. Using "%" stops searches working where there are more than word in the search term and they are not connected.

Example:

There is a manufacturer called 'Bowers & Wilkins'. Some people search for 'Bowers and Wilkins'. To make this manufacturer show up no matter if the user uses the "and" or or the "&" I do a str_replace on trhe search term to remove both the "&" and "and" so there are just the two words 'Bowers' and 'Wilkins. Then the search works as the two words are present even thought they are not one after the other.

(I hope that makes sense)!

Can you tell me more about your 'backticks' suggestion as I'm not sure what you mean?

Thanks. 

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
 Share

×
×
  • Create New...