Saltar navegación

[Resuelto] Conditionals don’t show the view

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
The user created a conditional shortcode that was not working as expected.

Solution:
It turned out that the user was checking a custom field in a related post. This can't be done, we can only check for custom fields of the current post, or we need to use the item attribute to change the post that we are checking.
Or we can pass the custom field in a view shortcode argument then check it using the [wpv-attribute] shortcode.

Relevant Documentation:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute

This support ticket is created hace 4 años, 2 meses. 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 – 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: Africa/Casablanca (GMT+01:00)

Etiquetado: ,

Este tema contiene 20 respuestas, tiene 2 mensajes.

Última actualización por miquelF-2 hace 4 años, 1 mes.

Asistido por: Jamal.

Autor
Mensajes
#1894653

I don't know, what is it that you want to know if it will work? The conditional on the product's templates?

#1894669

Yes. At the moment the wiew always show "More Previous Works" and it must show "More Available Works" when the product in the template is on sale or in stock and "More Previous Works" when the product in the template is out of stock.

Can you help me?

#1894707

"More Previous Works" is part of the view "Other Previous Works in Artwork Page" which I added to the content template of the view

"More Previous Works" is part of the view "Other Previous Works in Artwork Page" which was not part fo the content template of the view "Other Artworks in Artwork Page"

I put both of them now, and we can see both strings:
- enlace oculto
- enlace oculto

#1894721

Thanks but I need that only show "More Previous Works" when the Main Artwork is out of stock by example: enlace oculto

and only show " More Available Works" when the Main Artwork is instock or by example: enlace oculto

#1895089

Both of the views that display the previous or available works from the same Artist are used inside the view "Other Previous Works in Artwork Page". This view does not have visibility over the data(stock info) of the main artwork. We can pass it to it using a shortcode, but we'll need to include it inside the Elementor template using shortcodes. Currently, it is added using an Elementor module(the view module) as you can see here enlace oculto

We'll be using the wpv-attribute shortcode to get the value of the stock from the main Artwork. Read more about it here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute

Then, in the "Other Previous Works in Artwork Page", we'll wrap each of the views, that display the previous or available artworks, in the conditional shortcode:

[wpv-conditional if="( '[wpv-attribute name='stock']' eq 'instock' )"]
	[wpv-view name="available-artworks-in-artwork-page-2"]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-attribute name='stock']' eq 'outofstock' )"]
	[wpv-view name="other-previous-works-in-artwork-page"]
[/wpv-conditional]

And that will do the trick. Check this screenshot enlace oculto

Keep in mind that a content template is meant to display only one post, and a view is meant to display a list of posts. A content template can be inside a view's loop in order to display the current post in the loop.

I hope this helps. Let me know if you have any questions.

#1896949

My issue is resolved now. Thank you!