Accueil › Toolset Professional Support › [Résolu] How to use conditional and output what we need
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)
Marqué : Content Templates, Types plugin, Views plugin
Documentation connexe :
Ce sujet contient 19 réponses, a 2 voix.
Dernière mise à jour par fred-r.M Il y a 5 années et 3 mois.
Assisté par: Minesh.
Tell us what you are trying to do?
We have 2 custom fields, one is for a youtube video, the other one for a vimeo video. Both fields can be empty.
- Location Video (location-video), Youtube embeded
- Vimeo Video (vimeo-video), only the url string
1. I like to have, if both fields are empty, that it shows the featured post image.
2. If the youtube field has something in, it use to show this video. The featured image needs to be showed.
3. If this field is empty, but the vimeo field is filled, it uses to show the vimeo player. The featured image needs to be showed.
Is there any documentation that you are following? I tried to find anything, we used to have it, like this, but not working with the new version of toolset:
<p>[wpv-conditional if="( $(wpcf-location-video) ne '' )"]<iframe width="853" height="480" src="[types field='location-video' output='raw'][/types]" frameborder="0" allowfullscreen=""></iframe>[/wpv-conditional]<br /> [wpv-conditional if="( $(wpcf-vimeo-video) ne '' )"]<iframe width="853" height="480" src="[types field='vimeo-video' output='raw'][/types]" frameborder="0" allowfullscreen=""></iframe>[/wpv-conditional] </p> <p>[wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) eq '' )"][wpv-post-featured-image size='center' class='img-responsive']</p> <div id="pin_btm"><a data-pin-do="buttonBookmark" href="<em><u>lien caché</u></em>" data-pin-tall="true"></a></div> <p>[/wpv-conditional]</p>
Is there a similar example that we can see?
lien caché
What is the link to your site?
lien caché
- if both fields are empty - show only featured image - correct
- if location-video is empty and vimeo-video is NOT empty - show vimeo, but not show featured image
- if location-video is NOT empty and vimeo-video is empty - show Youtube, but not show featured image
Can you please try the following code and try to resolve your issue:
[wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) eq '' )"] [wpv-post-featured-image size='center' class='img-responsive'] <div id="pin_btm"><a data-pin-do="buttonBookmark" href="<em><u>lien caché</u></em>" data-pin-tall="true"></a></div> [/wpv-conditional] [wpv-conditional if="( $(wpcf-location-video) ne '' ) AND ( $(wpcf-vimeo-video) eq '' )"] <iframe width="853" height="480" src="[types field='location-video' output='raw'][/types]" frameborder="0" allowfullscreen=""></iframe> [/wpv-conditional] [wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) ne '' )"] <iframe width="853" height="480" src="[types field='vimeo-video' output='raw'][/types]" frameborder="0" allowfullscreen=""></iframe> [/wpv-conditional]
Hi
Please check: lien caché
I get now a 404, where the iframe needs to be, with the follow source code:
<iframe src="[types field='location-video' output='raw'][/types]" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
On this link: lien caché
As we not have both videos, it shows first the image, would be okay, but then it shows 404, where iframes are - they not need to show there
Can you please share admin access details so I can see how you setup the things in backend.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Hi
lien caché
When I use this code
[wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) eq '' )"][wpv-post-featured-image size='center' class='img-responsive'] [wpv-conditional if="( $(wpcf-location-video) ne '' ) AND ( $(wpcf-vimeo-video) eq '' )"][types field='location-video'][/types] [wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) ne '' )"]<iframe src="[types field='vimeo-video' output='raw'][/types]" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
It shows the image as first, then the youtube video as second. And it likes to show the vimeo too.
If I use this code:
[wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) eq '' )"][wpv-post-featured-image size='center' class='img-responsive'][/wpv-conditional] [wpv-conditional if="( $(wpcf-location-video) ne '' ) AND ( $(wpcf-vimeo-video) eq '' )"][types field='location-video'][/types][/wpv-conditional] [wpv-conditional if="( $(wpcf-location-video) eq '' ) AND ( $(wpcf-vimeo-video) ne '' )"]<iframe src="[types field='vimeo-video' output='raw'][/types]" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>[/wpv-conditional]
It shows me [types field='location-video'][/types] - but no image.
So, we need to get the logic for showing what needs to get showed first. Then we need to work on the way how it shows. With your code, so additional [/wpv-conditional] - it not showing correct as it needs to be.
For the youtube video, as it is an embedded media, only show [types field='location-video'][/types] will show the video correct.
so that is expected. Every conditional statement needs to be closed with [/wpv-conditional].
if [types field='location-video'][/types] holds the embedded content yu only need to display [types field='location-video'][/types].
Do you mean that with both the places where you display location-video and vimeo-video if both are empty, on both places you wanted to display the featured image. I need to see how you added the location-video and vimeo-video to your page. Can you please send me screenshot or access detaials?
Hi
So, I am using a "page block" this is from the theme IMPREZA. Inside there, I am able to add either as text or raw html the toolset stuff.
Other fields are working, either also with conditional. Contitional is somehow not working, when having {!{ instaed of [.
Also the closing conditional is not working, it will gives me just the shortcode part back.
Only adding the featured image, is working. Only adding the youtube video is working, as this is embeded. Where I have a bit troubles, to get a vimeo video added. But not sure, if we have this field filled in.
Regards,
Simon
I need to check on your install how you added the fields and where its braking the things. Can you please share problem URL and access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Hi
Is there a way how I can check it? Or debug it? As I wrote earlier, it seems as the logic is not working as it needs to.
Regards
You can add the attribute debug="true" to your conditional statement:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#debugging-conditional-output-in-views
If that does not help, please check the following:
=> https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/
Hi
It seems, as it is not possible to show a field with a short code:
[wpv-conditional if="( $(wpcf-location-video) ne '' )"][types field='location-video' output='raw'][/types][/wpv-conditional]
This gives me [types field='location-video' output='raw'][/types], expected the url from the youtube video
[wpv-conditional if="( $(wpcf-location-video) ne '' )"][types field='location-video' output='raw'][/types]
This gives me the url from the youtube video
This:
[wpv-conditional if="( $(wpcf-location-video) ne '' )"]<iframe width="853" height="480" src="<em><u>lien caché</u></em>" frameborder="0" allowfullscreen=""></iframe>[/wpv-conditional]
Is working too...
Any idea what it could be? Seems like shortcode in shortcode not working
I need problem URL and access details. Without checking how these conditional statements added from your backend I will not have any clue to give you and that help you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I'm checking the following page:
=> lien caché
But I do not find any conditional statement added to it. Can you please tell me where exactly you added those conditional statements which you mentioned in your reply here:
=> https://toolset.com/forums/topic/how-to-use-conditional-and-output-what-we-need/#post-1337287
Can you please share the link where you added those conditional statements.