Skip Navigation

[Resuelto] Split: Conditional display for the date field not working as expected

This support ticket is created hace 2 años. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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/Karachi (GMT+05:00)

Este tema contiene 9 respuestas, tiene 2 mensajes.

Última actualización por Waqar hace 2 años.

Asistido por: Waqar.

Autor
Mensajes
#2480551

Hi,

oh sorry - but it was in view 12454 - >

i tried it in loop object with condition:
[wpv-conditional if="( '[types field='ort' item='@termine-veranst.parent'][/types]' lte '[NOW]' )"]

or
[wpv-conditional if="( '[types field='datum-und-uhrzeit' style='text' format='d'][/types]' lte '[NOW]' )"]

but this dont work.

thx for helping - best regards - alex

#2480665

Hi,

Thank you for contacting us and I'd be happy to assist.

There are a couple of points to note here:

1. The right format to use the current time value is 'NOW()' and not '[NOW]'.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/date-filters/ )

2. The "ort" custom field is of type select and not a date/time type field. For date function comparisons, only the date/time fields or the fields which are storing the raw UNIX timestamp format should be used.

So, based on these the correct format to use for the current post's field with slug 'example-field' would be:


[wpv-conditional if="( $(wpcf-example-field) lte 'NOW()' )"]
The condition is true!
[/wpv-conditional]

And if the field is from the related parent/child post and you need to specify that through the 'item' attribute ( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ ) for example "@termine-veranst.parent", the format would be:


[wpv-conditional if="( '[types field='example-field' output='raw' item='@termine-veranst.parent'][/types]' lte 'NOW()' )"]
The condition is true!
[/wpv-conditional]

I hope this helps and please let me know if you need any further assistance with this.

regards,
Waqar

#2482521

Hi Waqar,

sorry but i had a hanger why show this the date it is without the output='raw' item='@termine-veranst.parent'

i looks it works like this but i wonder how (field="datum-und-uhrzeit" is possible, which is given to the posttype in view 12454):

 
[wpv-conditional if="( '[types field='datum-und-uhrzeit' output='raw' item='@termine-veranst.parent'][/types]' lte 'NOW()' )"]
The condition is true! [types field='datum-und-uhrzeit' ][/types]
[/wpv-conditional]

best regards - alex

#2482885

I'm sorry, but I couldn't fully understand the question.

If you meant to ask how the 'item' attribute can be used to get the data from the related posts, you'll find the details about that in this guide:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

In case of a different question, can you please share more details about what you have in mind?

#2482891

hi Waqar,

😉 - no i would hide any posts which is in future - lower or same like Now(). The Field "datum-und-uhrzeit" has a date which i can use it in an if-loop 😉 - but it dont work.

thx for helping - alex

#2485069

Thank you for sharing these details.

The outer condition in the view with ID '12454' was not working, because the shortcode was using the attribute item='@termine-veranst.parent'.


[wpv-conditional if="( '[types field='datum-und-uhrzeit' output='raw' item='@termine-veranst.parent'][/types]' lte 'NOW()' )"]
....
[/wpv-conditional]

Since the 'datum-und-uhrzeit' field is directly attached to the post type 'Termine' that this view is showing, the shortcode for it doesn't need the 'item' attribute.


[wpv-conditional if="( '[types field='datum-und-uhrzeit' output='raw'][/types]' lte 'NOW()' )"]
....
[/wpv-conditional]

I've updated the conditional statement and it seems to be working now.

#2485187

Hi Waqar,

yes but without it dont work - have you seen this -> enlace oculto

thx for you helping, best regards - alex

#2485195

Yes, I've seen this page and it is not showing any results because there are no posts which are fulfilling the criteria.

To demonstrate that the conditional statement itself is working correctly, I've created a new test view named "Test view from TS support", with the same settings and it can be seen on a new page named "Test Page from TS support".

You can see that this page is correctly showing only the posts which have the 'datum-und-uhrzeit' field value, lower than or equal to 'Now'.

The reason the view with ID '12454' is not showing any results is that it is undergoing some extra filtering through the custom code snippet named "tssupp-multi-rfg-parents", added at WP Admin -> Toolset -> Settings -> Custom Code.
( screenshot: enlace oculto )

If you'll remove this view's ID '12454' from that code snippet, it will also start showing the results correctly.

#2485221
Bildschirmfoto 2022-10-28 um 14.31.30.jpg

Hi Waqar,

yes you are right - now i ordering this view also about datum-und-uhrzeit: this is working - but now the filters wont work - do i see something wrong? -> look i filtered about kategories and date but nothing work.

#2486849

I've reviewed your previous ticket in which the custom snippet "tssupp-multi-rfg-parents" was shared.
( ref: https://toolset.com/forums/topic/filter-view-of-rfg-by-taxonomy-applied-to-parent-post/ )

As Toolset views, don't officially support the front-end search filters for the taxonomies and the custom fields attached to the related parent or child posts, this workaround of linking one view's results with another, can't be considered reliable or efficient.

A better approach, in this case, would be to use a single view that shows the "Veranstaltungen" posts with the desired search filters. And in the view's loop item template, you can show the related 'Termine' posts.