Skip Navigation

[Gelöst] Problem with conditional output

This support ticket is created vor 7 Jahre, 11 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 Antworten, has 2 Stimmen.

Last updated by joshB-6 vor 7 Jahre, 11 Monate.

Assisted by: Luo Yang.

Author
Artikel
#401598
hUfT2I.jpg

Hi there.

I have this annoying problem with a site I am working on.

The code below is the part of my view where it displays the Absentee bid form link. The absentee bid form is a field belonging to Sale which is the parent of Auction lot. The auction lots are displayed din the view.

[wpv-conditional if="( $(wpcf-end-date-datetime) gt 'TODAY' )" evaluate="false"]
              <br><b>Absentee Bid Form: </b><a href"[types field="absentee-bid-form" id="$sale" title="Download"] [/types]"></a>[/wpv-conditional]

The conditional output works fine except for the stray "> at the end of the link.

Now obviously if I remove the "> from after [/types] it breaks the code.

I also notice that it is appearing on previous sales where wpcf-end-date-datetime is in the past.

Your advice will be greatly appreciated.

Regards.
Josh

#401631

Update:

[wpv-conditional if="( $(wpcf-end-date-datetime) gt 'TODAY()' )" evaluate="false" debug="true"]
              <br><b>Absentee Bid Form: </b><a href="[types field="absentee-bid-form" id="$sale" title="Download"] [/types]"></a>[/wpv-conditional]

Looking deeper into the problem there are two things I am trying to accomplish:

1)
Display "absentee-bid-form" if "wpcf-end-date-datetime" is in the future.

"absentee-bid-form" is a field on the parent post "sale"
"wpcf-end-date-datetime" is a field on the parent post "sale"

Am I missing something to specify that "wpcf-end-date-datetime" belongs to the parent "sale"?

2)
If I break it down, the url works fine with:

<br><b>Absentee Bid Form: </b><a href="[types field="absentee-bid-form" id="$sale" title="Download"] [/types]"></a>

However displays with like this:
Absentee Bid Form: Download">

if I remove the "> from the code, it breaks.

In the simplest terms possible "display the absentee bidder form hyperlink only if the end date of the sale is greater than today.

#401799

Dear josh,

I assume the custom field "end-date-datetime" is a date field created with Types plugin
and the custom field "absentee-bid-form" is a URL field created with Types plugin
1) Display "absentee-bid-form" if "wpcf-end-date-datetime" is in the future.
That means the value of field "end-date-datetime" is larger than Today(), so your codes should be like this:

[wpv-conditional if="( $(wpcf-end-date-datetime) gt 'TODAY()' )" ]
...
[/wpv-conditional]

Without the attribute evaluate="false"

2) To display the URL link in the HTML a tag, you will need to use raw output in the Types shortcode, for example:

<br><b>Absentee Bid Form: </b><a href='[types field="absentee-bid-form" output="raw"][/types]'>Absentee Bid Form</a>

See below test site:
hidden link
user/pass: xgren/111111

Use below codes:
hidden link

end-date-datetime: [types field="end-date-datetime" style="text" format="Y-m-d"][/types]
[wpv-conditional if="( $(wpcf-end-date-datetime) gt 'TODAY()' )"]
<br><b>Absentee Bid Form: </b><a href='[types field="absentee-bid-form" output="raw"][/types]'>Absentee Bid Form</a>
[/wpv-conditional]

Hope it help

#401853

HI Luo

Thank you for your reply.

Unfortunately the code above doesnt help.
I inserted the code above and got the following output:
hidden link

I removed the first line because all I am trying to use the field "end-date-datetime" to display the field "absentee-bid-form" if the date is in the future.

This is what the admin dashboard of the sale looks like:
hidden link

I know there is no problem with the field because I am able to display the hyperlink to the absentee bid form on another page that only shows the CPT "sale":
hidden link

The condition i used on the above screenshot is:

[wpv-conditional if="( NOT(empty($(absentee-bid-form))) )"]
          <br>[types field="absentee-bid-form" title="Absentee bid form download"][/types]
          [/wpv-conditional]

Which leads me to believe that the problem lies in displaying a field belonging to the parent.
Is there somewhere in this code that we should be specifying that the fields "absentee-bid-form" and "wpcf-end-date-datetime" belongs to the parent $sale?

I guess I could move the fields from sale to auction lot CPT but I think that would be redundant as we have 10 000+ lots on the site already with about 30 000 more to come which will have a big impact on the database which is why i would prefer to use the parent fields.

regards,
Josh

#402108

You can use the parent field in the wpv-conditional shortcode, for example:

[wpv-conditional if="( '[wpv-post-field name="wpcf-end-date-datetime" id="$sale"]' gt 'TODAY()' )"]
Here display the Absentee Bid Form
[/wpv-conditional]

see the demo site:
hidden link
And front-end:
hidden link

#402124

Thank you so much Luo!
Makes perfect sense to use wpv-post-field name
That works perfectly.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.