3

Sorry for the convoluted question. Let me add some clarity to this:

I have a two channels: products & videos. On the videos channel I have custom field for a YouTube url along with a Playa field to relate the video to a specific product(s). I also tied the same category group the products channel is using to the video channel. I have this setup for two reasons:

  1. Client can add a video to a category so this video is shown on all products pages with that category
  2. Client has the option to relate the video to a specific product(s)

I realize I could potentially just use the Playa filter to get the correct entries and do a mass dump but I thought it would be a lot easier to just use a category if the video is a general overview of a certain product category.

How do I structure the conditional to show/hide if a video matches those options?

I'm using the awesome URL Helper addon for segment variables so I can easily do something like this on the single product page:

{exp:channel:entries
   category="{segment_2_category_id}"
   channel="videos"
   disable="category_fields|member_data|pagination|trackbacks"
   dynamic="no"
}
    show video stuff
    {if no_results}no video here{/if}
{/exp:channel:entries}

or use the Playa tag {exp:playa:total_parents} in a conditional. The problem is I need to check both before displaying the data

3

Well, I figured it out! I had to buy Entries Number add-on. This allowed me to find/search if any entries were tied to a certain category and return a number. Take note of the {segment_2_category_id} variable, this variable is from the URL Helper add-on I mentioned above. You could potentially use {segment_category_ids_any} to do an inclusive search also–which I'm using b/c I have true nested URI's domain.com/products/parent_cat/sub_cat/entry

{if {exp:playa:total_parents channel="videos"} > 0 || {exp:entries_number category="{segment_2_category_id}" channel="videos"}{entries_number}{/exp:entries_number} > 0}
    has video
{/if}

I'm still curious to see if anyone has any other solutions.

| improve this answer | |

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.