Skip Navigation

[Resolved] Conditional formatting with relationships

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 10 replies, has 2 voices.

Last updated by Christian Cox 5 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1311581

Hi,

I have a post type (TV Show) that has a relationship with a post type (Products).

I want some content to appear but only if there is some products linked with a TV show using their relationship.

So I tried using the following conditional formatting but it didn't work, the idea of the below is to check if product name is blank or not, if not blank then shows the content.

[wpv-conditional if="( $(wpcf-product-name).item(@tv-show-product.parent) ne '' )"]Content[/wpv-conditional]

Am I missing something obvious here on how to do this?

#1311627

The easiest way to do this is with a View, filtered by this post relationship. Depending on where you want it to display, you would choose the other post type as the content for the View. You can leave the wpv-loop section empty. In the wpv-items-found section (but outside of the wpv-loop) you can add the content you want to display if there are related Products. You may need to use the post selection tab to select the other post type here if the information is in the TV show. In the wpv-no-items-found section, you can display something else, or nothing at all.

#1312477

Ah ok yeah that worked, although when no results I set the view to have no content but its still adding space where the view would be if it was there. Anyway to avoid it adding white space in the content when no results?

#1312481

First I would check the "disable the wrapping DIV' in the View editor and remove all white spaces and line breaks from the loop and the "no items found" section. Then if that still isn't working as expected I would use the Loop Wizard to recreate the Loop using the "list with separators" option. I'll be glad to take a look if those aren't working.

#1312553

Hey Christian,

I have tried this but doesn't seem to have made any difference 🙁

Do you want to login and take a look? See if you can see something I have missed.

#1312559

Sure, where can I test it on the front-end?

#1312561

Hey Christian

So this page WONT show any products (DVDs in this case) - hidden link

This one will (I am not sure if you really need to see one where the products appear but just in case you do): hidden link

Cheers!

#1312581

Looks like the login you created for me isn't working any more, can you provide new credentials? I'll take a look in wp-admin.

#1313859
Screen Shot 2019-08-11 at 11.20.55 AM.png
Screen Shot 2019-08-11 at 11.21.06 AM.png

Okay I ran a quick test by adding some hidden text just before the "product-filtered-list-for-tv-show-page" View in the TV Show Content Template. I don't see any extra space here in the page markup. Am I misunderstanding where the space can be seen?

#1314675

Ah it is due to some strange padding around the video content above it.

Must have just never noticed it before! Has always been that much of a space.

#1314767

I understand, that makes sense!