Skip Navigation

[Gelöst] Conditional using shortcode in if not working

This support ticket is created vor 4 Jahre, 1 Monat. 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 17 Antworten, has 3 Stimmen.

Last updated by chrisH-10 vor 4 Jahre, 1 Monat.

Assisted by: Shane.

Author
Artikel
#1531245

Sorry to be annoying but I have this ticket I need a faster resolution to. The below is assigned to Minesh. He's not in my timezone and we haven't started to resolve the issue. Please help.
If you're not able to, the ticket I reference in the below was answered by Shane who also happens to be in my timezone.

https://toolset.com/forums/topic/conditional-using-shortcode-in-if-not-working/#post-1530705

#1531247
#1531423

Minesh
Supporter

Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Are you still around - please let me know - I'm here to help.

#1532669

You agreed that this timezone is an issue.

1. Why did you not re-assign the ticket?
2. Why did you not address the reassignment issue at all?

#1532721

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

I took a look at the issue for you.

Currently it seems that you're not able to check the parent fields in the conditionals at the moment. I remember this being possible previously but could be a bug in this version.

I would recommend that you get this done using some custom code. What you can perhaps do is wrap our shortcode to get the field in another custom shortcode and then pass that shortcode into the conditionals.

Thanks,
Shane

#1532741

Thanks Shane! I have started into writing a custom shortcode for this.

In the process I'm afraid I found another issue. Once I removed the wpv-conditional I found that 5 of 18 pages do not show the content of their fields (e.g. /ideas/principles/emerging-technology/)
[types field='index-description-2' item='$parent'][/types]
[types field='index-description-3' item='$parent'][/types]
even though they have contents entered in the back end. This issue may be related in that the $parent thing doesn't appear to work. It also shows this to be an intermittent issue or at least it's odd and probably complex.

Can I roll back to a version where this works as documented?

#1532779

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

Yes you can try rolling back as i'm currently testing the problem on my end.

I'm actually trying to replicate it. Once I'm able to I will make a report to our 2nd tier supporters but I dont suspect that a solution will come quickly if i'm able to discover a bug.

Thanks,
Shane

#1532781

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-02-28 at 2.59.06 PM.png
Screenshot 2020-02-28 at 2.58.57 PM.png
Screenshot 2020-02-28 at 2.58.51 PM.png

Its definitely an issue isolated to your end as i'm not able to replicate. See Screenshots.

#1532833

I'm busy writing code to the this shipped but a brief observation is that I'm using
<wpv-loop wrap="7">
[wpv-item index=1]...
Could that be a factor?

#1533161

Well, I wrote a shortcode that I use in the wpv-conditional to do my bidding.

This works as intended leading me to the conclusion that wpv-conditional works fine.
The issue then must be the [types field='index-description-2' item='$parent'][/types] expression, at least when it's provided as a value to the if. To test that idea further I tried providing the if a value of [wpv-post-field name="wpcf-index-description-2" item='$parent']. This was apparently also not evaluated. I think they must evaluate correctly but something messes up (a) the context in the wpv-conditional code where this code is do_shortcode-ed or (b) there is something in the rendered field that makes it fail. To check on the later suspicion I cleaned the field in text mode so there was no weird markup.

Before I did all that I tried using $current_page instead of $parent. That yields curious results:
(1) See this page
hidden link. The first time through the loop $parent does not work. The second loop (further down the page) both $current_page and $parent work.
(2) Then check out hidden link here only $parent works!?

#1535615

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

Happy to see you were able to work around the issue.

I too have come to the conclusion that in your site's case the issue occurs when you add the item parameter with an attribute like the $parent.

In other cases it works. It could just be a case where it breaks in the View Loop but works outside the loop.

There is still some testing that needs to be done here but so far I'm not able to replicate the issue.

However there is one thing I need for you to try for me on your end. If you edit a regular post and add the [types field='index-description-2' item='$parent'][/types] expression in the conditional does it still work ?

In my case on my test site it works but wanted to confirm that on your end its not a cause where it is completely broken in the conditionals.

Thanks,
Shane

#1536181

I'm not quite sure I understand your request:
However there is one thing I need for you to try for me on your end. If you edit a regular post and add the [types field='index-description-2' item='$parent'][/types] expression in the conditional does it still work ?

The regular post is the parent to the view. The post's parent would not have this field. Indeed when I add this shortcode on a post it comes back blank.
hidden link

I also put that shortcode in the Content Template and that as expected comes back blank as well.
hidden link

So then I thought perhaps he means a child post that is listed. So I added the shortcode to the excerpt. That post is a child and indeed the content appears.
hidden link

Let me know if I can try anything else.

#1536185

FYI I tried turning off all plugins but toolset and that did not change the mixed results.

#1537693

Shane
Supporter

Languages: Englisch (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-03-03 at 1.40.21 PM.png
Screenshot 2020-03-03 at 1.40.13 PM.png

Hi Chris,

Thank you for running the tests for me. I've concluded that the issue is definitely on your end as I've setup a similar scenario like your post and it works. See Screenshot

As you can see the parent information is being retrieved as intended in the conditional.

Would you mind if I went onto your site to take a copy for further debugging steps to see if I can identify anything on your site that would point me to the issue.

Thanks,
Shane

#1537825

Feel free to take a copy. Please let me know when you are done and will take it down.

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