0

I have two channels: blog and recipes. Blog posts are about recipes, so one of the fields in the blog channel is a relationship field connected to the recipes channel. Each blog entry has a related recipe entry.

I want to let visitors search for terms in the body field of the blog channel as well as in the ingredients field of the recipes channel, but only show the related entry (the recipe) in the search results.

So let's say there's a blog post about pizza, connected to a related recipe for pizza. Within the body field of the blog entry, the author has typed "my kids love this." Within the ingredients field of the recipe entry, the author has typed "mozzarella".

I want the pizza recipe entry to show in the results if the user searches for "mozzarella" and also if the user searches for "my kids love this".

Is this possible?

[EDIT]

It seems like the logic I need is something like, "if a result is found in the Recipes channel, then display that entry. If the result is found in the Blog channel, then display that entry's related Recipes channel entry."

1 Answer 1

0

Filtering entries by a child entry's keywords will require a custom filter, so isn't possible out of the box.

if a result is found in the Recipes channel, then display that entry. If the result is found in the Blog channel, then display that entry's related Recipes channel entry.

This is possible out of the box. If you create 2 collections -- one for Recipes, one for Blog -- you can search both collections and in the Results tag use conditionals to display different types of content depending on the channel.

The gotcha here is that the excerpt will belong to the collection/channel the entry was found in. And if you're displaying the related Recipe entry for a found Blog entry, it is possible that that specific Recipe entry was already displayed. So there's a chance of duplicate results. One way around that is to also display some Blog entry information there, so it looks different.

3
  • That's exactly what I did and those are indeed the results I'm getting: duplicate results. Okay, thanks a lot for the help, Low. I'll figure something out.
    – Mike Mella
    Sep 25, 2015 at 14:38
  • @MikeMella we have a similar challenge, but in reverse... we ONLY want to search entries that are parents of a specific entry. Did you resolve this?
    – paulcripps
    Oct 17, 2015 at 16:02
  • @paulcripps Not really. My client agreed to only search and show results from one channel.
    – Mike Mella
    Oct 19, 2015 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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