Skip Navigation

[Resolved] Test empty value

This thread is resolved. Here is a description of the problem and solution.

Problem:

The essential issue here is that the customer wants to check if a specific field is empty on his posts.

Solution:

To do this you will need to use our conditional shortcode to check for the empty field.

Example

 
[wpv-conditional if="( empty($(wpcf-test-field)) )"]
 
 
Shortcode to display post information.
 
[/wpv-conditional]

For more information on checking for empty fields you can take a look at the link below.

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created 6 years, 1 month 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
- 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 12 replies, has 2 voices.

Last updated by fulvioT 6 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#624627

Hi,

I have a date field not obligatory and I want to create a view to see all the post in which this fields is empty.

I set a view with a filter on this field compared both as a string both as a number with "NO value" in constant but doesn't work.

In your page support at https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/ you explain the procedures with reference an old plugin I suppose because my options are different.

thanks
fulvio

#624658

Shane
Supporter

Languages: English (English )

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

Hi Fulvio,

Thank you for contacting our support forum.

What I would recommend that you do is to create a view without a filter that would list out all the posts.

Then wrap the code that is placed within the <wpv-loop></wpv-loop> tags inside the conditional tags to check if the field is empty.

Example.

<wpv-loop>

[wpv-conditional if="( empty($(wpcf-test-field)) )"]


Shortcode to display post information.

[/wpv-conditional]
</wpv-loop> 

Note this will only display the information of the posts where the field is empty, also you will need to replace "wpcf-test-field" with "wpcf-{myfieldslug}".

Please let me know if this helps.
Thanks,
Shane

#624740

Thank you for your instruction but I prefer operate with filter because in other view I have to put other filter togheter this test for empty fileds.

is it possiile to operate with normal filter ?

thanks
fulvio

#624771

Shane
Supporter

Languages: English (English )

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

Hi Fulvio,

It may not work with the filter itself because the query filters don't check for empty values.

The way to do it is with the conditional tags.

The query filters are for filter through comparable parameters.

Thanks,
Shane

#624869
#624876

Hi,

I try to insert your code in view but it seems doesn't work

<wpv-loop>
[wpv-conditional if="( empty($(wpcf-fine-validita)) )"]
<div class="panel panel-default">
<div class="panel-body">
[wpv-post-body view_template="Elemento del ciclo in Normativa in Vigore"]
</div>
</div>
[/wpv-conditional]
</wpv-loop>

the view shows no one elements
what I wrong?
fulvio

#624936

Shane
Supporter

Languages: English (English )

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

Hi Fulvio,

No worries I can check on this for you if you'll like so that I can see exactly whats wrong.

Would you mind providing me with admin access to the website and this view so that I can have a look?

The private fields will be enabled for your next response.

Thanks,
Shane

#625101

Shane
Supporter

Languages: English (English )

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

Hi Fulvio,

I've got some bad news. So this actually won't be possible to do because our Date fields do not save to the database unless there is a value added to that field.

So you wouldn't be able to filter for all the posts that don't have that date field inserted.

What you can do is to add a marker on the posts such as a checkbox to identify these posts and then filter for that checkbox.

Please let me know helps.
Thanks,

#625206

Hi,

thanks for your help.

Now I have to set another view.
I have 2 parameters to manage and I want that the second one has the same value of first without asking it into a form.
Is it possible to assign the value of the first parameter to a second one?
How.
If you need to see the view you can see it at "Normativa alla Data" view - that at this moment ask two parameters but I want to eliminate the second one and assign the value of the first to the second one by code.
You have the user to login in the previous message
thank
fulvio

#625316

Shane
Supporter

Languages: English (English )

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

Hi Fulvio,

So to get this clear you want to filter both field by the same exact value that was entered into one of the date fields ?

Thanks,
Shane

#625319

Yes

I want to enter one date parameter and test both data-inizio and data-fine fields.

I thought to assign by code the value fo parameter to first and second fields or I enter a first field parameter and assign it to a second one.

thank
fuvio

#625435

Shane
Supporter

Languages: English (English )

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

Screen Shot 2018-03-15 at 1.22.43 PM.png

Hi Fulvio,

You should be able to do this by copying the url parameter from the first filter into the second one. See Screenshot.

Please let me know if this helps.
Thanks,
Shane

#625547

Hi,

sorry but I don't understand. In the screen shot I see the exact view I created in which two parameters are to be put into.
I work out putting the same parameter for both field.
thank
fulvio

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