Skip Navigation

[Resolved] Using a Conditional Shortcode based on the value of a intermediary child value

This support ticket is created 5 years, 5 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by CharleneD1435 5 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1305075

Tell us what you are trying to do?
I am trying to set a restriction to show a column with it's content, only when the value of a field from a intermediary child =! empty.

Here's what I got so far:

<div class="row">
<div class="col-md-2">[wpv-post-featured-image item="@skill-effect.child"]</div>
<div class="col-md-10">[wpv-post-title item="@skill-effect.child"]
<div class="row">
[wpv-conditional if="( $(wpcf-duration) ne '' )"]<div class="col">[types field='duration' format='FIELD_NAME: FIELD_VALUE Turns' item='@skill-effect.intermediary'][/types]</div>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-chance) ne '' )"]<div class="col">[types field='chance' format='FIELD_NAME: FIELD_VALUE %' item='@skill-effect.intermediary'][/types]</div>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-value) ne '' )"]<div class="col">[types field='value' format='Amount: FIELD_VALUE %' item='@skill-effect.intermediary'][/types]</div>[/wpv-conditional]
</div>
</div>
</div>

The issue is that I'm not entirely sure what to place in the IF statement, wpcf-duration is a field group field I don't think it's the correct one though. But if I use the wizard I cannot choose the actual fields I want to use in my statement.

So what it is supposed to do is to check if the field ">[types field='duration' format='FIELD_NAME: FIELD_VALUE Turns' item='@skill-effect.intermediary'] which is as this shortcode shows a intermediary field from the connection between a skill and it's effect. These connections have durations, chance and value set for them. However not each of them as every value.
So what I would like to do is show these fields only if there is a value set for them. So they will not show when there is data for the fields.

What am I doing wrong and how would I need to go about this?

#1305105

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

These connections have durations, chance and value set for them.
=> Can you please share screenshot how you setup the custom fields for intermediary post types?

#1305305
WhatsApp Image 2019-07-31 at 11.33.26.jpeg
WhatsApp Image 2019-07-31 at 11.32.30.jpeg

I hope these images can clarify what I meant, these are the fields I need to set the conditional to. If these fields are empty than the column should not show. If they are set with a value than the column should show.

#1305349

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try to use the shortcode inside the conditional statement:

[wpv-conditional if="( '[types field='duration' item='@skill-effect.intermediary']' ne '' )"]<div class="col">[types field='duration' format='FIELD_NAME: FIELD_VALUE Turns' item='@skill-effect.intermediary'][/types]</div>[
/wpv-conditional]

[wpv-conditional if="( '[types field='chance' item='@skill-effect.intermediary']' ne '' )"]<div class="col">[types field='chance' format='FIELD_NAME: FIELD_VALUE %' item='@skill-effect.intermediary'][/types]</div>[/wpv-conditional]

[wpv-conditional if="( '[types field='value' item='@skill-effect.intermediary']' ne '' )"]<div class="col">[types field='chance' format='FIELD_NAME: FIELD_VALUE %' item='@skill-effect.intermediary'][/types]</div>[/wpv-conditional]
#1305393

Thank you that seemed to have done the trick!
I had tried to copy the entire shortcode including the value field name part but that did not work.
Sometimes the solution is so simple you just overlook it haha.
Have a nice day further 🙂