Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Exclude keyword from search results

 

 


waterdancer
Novice

Aug 19, 2011, 3:53 PM

Post #1 of 13 (8586 views)
Shortcut
Exclude keyword from search results Can't Post

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?


Dave
Staff / Moderator


Aug 19, 2011, 6:29 PM

Post #2 of 13 (8580 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

Maybe with a where option?

'where' => " brand != 'xerox' ",

Dave Edis - Senior Developer
interactivetools.com
 


waterdancer
Novice

Aug 20, 2011, 11:41 AM

Post #3 of 13 (8322 views)
Shortcut
Re: [Dave] Exclude keyword from search results [In reply to] Can't Post

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.


Dave
Staff / Moderator


Aug 20, 2011, 12:53 PM

Post #4 of 13 (8321 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

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
 


waterdancer
Novice

Aug 21, 2011, 11:17 AM

Post #5 of 13 (8191 views)
Shortcut
Re: [Dave] Exclude keyword from search results [In reply to] Can't Post

Hi,

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


Dave
Staff / Moderator


Aug 21, 2011, 12:46 PM

Post #6 of 13 (8187 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

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
 


waterdancer
Novice

Aug 21, 2011, 2:48 PM

Post #7 of 13 (8169 views)
Shortcut
Re: [Dave] Exclude keyword from search results [In reply to] Can't Post

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


Dave
Staff / Moderator


Aug 21, 2011, 10:10 PM

Post #8 of 13 (8123 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

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
 


waterdancer
Novice

Aug 22, 2011, 10:03 AM

Post #9 of 13 (7972 views)
Shortcut
Re: [Dave] Exclude keyword from search results [In reply to] Can't Post

Hi Dave,

Let me know if you receive the upload. First time doing this in a forum.
Attachments: search-results.php (7.06 KB)


Jason
Staff / Moderator


Aug 22, 2011, 1:36 PM

Post #10 of 13 (7957 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

Hi,

The code would look something like this:


Code
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 - Programmer 
interactivetools.com

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


waterdancer
Novice

Aug 23, 2011, 9:49 AM

Post #11 of 13 (7740 views)
Shortcut
Re: [Jason] Exclude keyword from search results [In reply to] Can't Post

Still not working.

I plugged into the search results template the following:

list($productsRecords, $productsMetaData) = getRecords(array( 'tableName' => 'products', 'perPage' => '10', 'where' => "name != 'miele'", ));

However, Miele products keeps showing up in the results. Am I placing the code in the correct page?


Jason
Staff / Moderator


Aug 23, 2011, 9:54 AM

Post #12 of 13 (7737 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

Hi,

If you could fill out a 2nd Level Support Request I can take a quick look and see what's going on.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


Jason
Staff / Moderator


Aug 23, 2011, 10:58 AM

Post #13 of 13 (7692 views)
Shortcut
Re: [waterdancer] Exclude keyword from search results [In reply to] Can't Post

Hi,

I took a look and I think I found the problem. Since the Miele is only part of the name, and not the entire name, we need to use the MySQL LIKE function. I changed the query to this:


Code
list($productsRecords, $productsMetaData) = getRecords(array( 
'tableName' => 'products',
'perPage' => '10',
'where' => "name NOT LIKE 'miele%'",
));


This seems to be working now.

Hope this helps,
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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