2

Using EEs native Search, is there a way to exclude specific entries from the results?

Enabling, 'Is field searchable?' in the field settings tells EE which fields to use but these are global to the whole Channel.

I've got 4 entries I specifically don't want showing in the results. I'm manually excluding using if statements, hopefully there's a more elegant way of doing this?

1
  • Thanks for the responses. My feeling now is this would be good for EE to handle, so FR. The search module needs a per entry exclusion in the options tab. Dec 5 '13 at 10:12
3

There isn't really an elegant way to do this... All ways are "creative". Using the conditional to exclude is the easiest way IMO because it only affects that template.

2
  • Normally I'd agree but I've had situations where the client needs to determine whether or not something will appear in search results. To that end, statuses seemed the logical way to do it.
    – foamcow
    Dec 4 '13 at 16:50
  • 1
    Agreed. If the client needs to control what shows, then it a status totally makes sense. If they don't, the conditional is the best way so you don't have to change status on all your other tags.
    – Anna_MediaGirl
    Dec 4 '13 at 16:55
3

I set up a status for "hide from search" or similar. This means that the results aren't shown as my search is only showing open entries.

Of course, it does mean that you need to set any entries tags that are meant to show these entries to include the status as well as just showing those with a status of "open".

4
  • That's a clever idea. Unfortunately this is a product catalogue and I'm already using status for other functionality, like 'featured' and 'side panel'. Of course you can't have multiple statuses for an entry. Dec 5 '13 at 10:11
  • Then you would need to resort to a custom field (a checkbox) to say, hide from search results then use a conditional. It's probably too late but I wouldn't use Status the way you have - to control position/location since that's not an entry's status.
    – foamcow
    Dec 5 '13 at 12:36
  • It still feels kinda hacky, having a conditional as EE's loops through the results. Should really be in the SQL, over to EL for that. No worries, I hear you re status ;-). The status are really a status of the product, those were off top-of-head eg. Dec 6 '13 at 13:00
  • If you use a custom field then you could use a search= parameter in your channel:entries tag to only return the actual results rather than suppress the output of non-matches.
    – foamcow
    Dec 6 '13 at 19:09
1

I would go with conditional statement as well, this is probably the easiest/fastest and most effective (as @Anna_MediaGirl mentioned above) way to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.