Home › Toolset Professional Support › [Waiting for user feedback] Conditional inside a view doesn’t work
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.
Tagged: Views plugin
This topic contains 14 replies, has 1 voice.
Last updated by Christopher Amirian 1 week, 2 days ago.
Assisted by: Christopher Amirian.
I need to use a conditional, using a field, inside a view. I'm in content template, and this view is about a related custom post. Template is for "places", and view is for "venues" in this places. I try to use a condition on the venue's view. "If a field is 1", show this. As I don't have "else", I also use NOT "If a field is 1", to show another thing. But second condition is always true.
1st condtion
( ( '[wpv-post-field name="llum-natural" ]' eq '1' ) )
2nd condition
NOT ( ( '[wpv-post-field name="llum-natural" ]' eq '1' ) )
I attach an example with debug activated.
Thank you
Hello. Thank you for contacting the Toolset support.
Instead of using the NOT with your condition.
As I understand, you want to display something else when field is not set or it does not have value equal to 1.
What if you adjust the condition as given under with your conditional shortcode.
( '[wpv-post-field name="llum-natural" ]' eq '' )
Does that helps?
Hi!
I've changed the condition following your idea, but it doesn't work. In the second conditional, field is not used:
####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' = '' )
[debug] => true
)
####################
Debug information
####################
--------------------
Original expression: ( '' = '' )
--------------------
This is the debug information.
Thank you!
I'm not sure why field is not used for you.
What exactly you want.
You want to display something when field value is equal to 1.
And now, you want to display something else when field value is empty?
Can you please share problem URL where with what post I can test the conditoin against and also share your exact requirement.
Hi,
there is a field called llum-solar that indicates if a venue has natural sunlight or not. If the field is '1', I need to show venue's name followed by a sun icon. If not, just the name. As I can't use a "else", I've created two conditions, one for field = 1, and one for not(field = 1), or now field=''. This second condition is the one is not working.
If you look a this url
hidden link
you can see there are some venues with sunlight, and other without. The ones with sunlight show the name twice, because second condition is always true.
Thanks!!
Can you please check now: hidden link
I've adjusted the codnitional statement as given under:
( ( '[wpv-post-field name="wpcf-llum-natural" ]' eq '' ) )
Can you please check now and confirm it works as expected.
Hi,
it works as expected, in Catalan. But it doesn't work in Spanish or English.
hidden link
But also, I don't know why it works in Catalan... This is the same I tried before using 'NOT'.
Thanks!
Ahh - I see you are using WPML.
Have you checked the following Docs:
- https://toolset.com/course-lesson/how-to-prepare-the-site-to-run-multilingual/
- https://toolset.com/course-lesson/translating-views-content-templates-archives-and-forms/
I see you are using cache as well - Please try to delete the cache and check.
If your issue still persists - what if you try to use the conditional shortcode instead of conditional block. You can add the following conditional shortcodes by adding shortcode block to your content template
[wpv-conditional if="( '[types field='llum-natural' output='raw'][/types]' eq '1' )"] your code goes here [/wpv-conditional] [wpv-conditional if="( '[types field='llum-natural' output='raw'][/types]' eq '' )"] your code goes here [/wpv-conditional]
Hi,
This is Christopher following up on the issue. Would you please check that the field itself is not translated? If so then the conditional will not work.
And usually the page that the view is used should be refreshed:
- Go to your Dashboard > Pages.
- Open the edit screen of the original page. You should see a pencil/circle/gear icon in the sidebar options under the "Languages" section.
- Make a small change, for example, add an extra blank space at the end of a sentence/paragraph.
- Save it.
- You should now see that a circular arrow appears beside the 2nd languages links, this means that an update is required.
- Edit the translation again and save it up to 100% translated.
Also I could not find the aection in the page that you use dthe conditional can you give some screenshots?
Thanks.
Have you tired what Christopher suggested:
- https://toolset.com/forums/topic/conditional-inside-a-view-doesnt-work/#post-2813618
Hi Christopher,
the field has "Copy from original to translation". Please find attached an screenshot, and another from content template.
And about your other suggestion, the issue is in a Toolset Content Template, "Single Ubicació". If I make a change in main language, the circular arrow appears in the other languages.
Thank you!
Hi,
Thank you. I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
I will need to test and see the result.
Hi,
Thank you for the login information. I do see that even if I set the item to not translatable, it still shows as translatable in the sidebar.
Would you please give us login information for a copy of the website?
We will need to turn off plugins and do changes that might break the website and we need a version that we can freely troubleshoot.
Thanks.
Hi Christopher,
I'll create a copy in another server, and send you the login data ASAP,
thank you,