Exclude keyword from search results

Hi,

I need to exclude a brand name of products from the CMS search results without deleting the actual pages. I only need to exclude the name of the brand. Does anyone know how this can be accomplished or what the code it I need to add?

Re: [waterdancer] Exclude keyword from search results

By Dave - August 19, 2011

Maybe with a where option?

'where' => " brand != 'xerox' ",
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Exclude keyword from search results

Hi Dave,

Where exactly do I place that code? Is this the exact code I use? 'where' => " brand != 'xerox' "; (change xerox to the name I need to exclude)

I know HTML, but not so much PHP.

Thank you.

Re: [waterdancer] Exclude keyword from search results

By Dave - August 20, 2011

Hi waterdancer,

Replace "brand" with the fieldname you use to store brands in, and "xerox" with the brand you want to exclude, and then add that line to your getRecords() code at the top of your viewer page.

Give that a try and if it doesn't work attach your viewer page with the "Upload Attachment" feature and I'll take a look at the code for you.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Exclude keyword from search results

Hi,

I don't have a viewer page. Are you talking about search-results.php?

Re: [waterdancer] Exclude keyword from search results

By Dave - August 21, 2011

Hi waterdancer,

Yes, we call the pages with the generated code "viewer pages", but search-results.php is likely it.

Any luck adding the code?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Exclude keyword from search results

Doesn't work. I receive a blank page with this: MySQL Error: Unknown column 'type' in 'where clause'

Re: [waterdancer] Exclude keyword from search results

By Dave - August 22, 2011

Can you attach your page with the "Upload Attachment" feature and I'll take a look at the code for you? Thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [waterdancer] Exclude keyword from search results

By Jason - August 22, 2011

Hi,

The code would look something like this:

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'perPage' => '10',
'where' => "brand != 'xerox'",

));


In this example, we are saying don't return any records from the products section that have "xerox" in their brand field. All you should need to do is replace "brand" with the name of the field where you are storing your brands, and "xerox" with the name of the brand you want to exclude.

Give this a try and let me know if you run into any problems.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/