[Cerrado] Nesting Content Template Inside Conditional Statement Inside a View
This support ticket is created hace 3 años, 1 mes. 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 – 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)
Este tema contiene 7 respuestas, tiene 4 mensajes.
I have a content template for single products. Inside that content template I have a view for displaying related products. Inside that view, I setup two conditional blocks within the view output:
Depending on which condition is true, it is set to display one of two content templates. However, it only ever shows the content template from condition 2 above, even if condition 1 is true. I have set the conditional block to debug mode and it says the condition is evaluated as being true, yet it is still displaying the wrong content template.
Any assistance you can provide in troubleshooting would be appreciated. Thanks.
As a follow-up, I also tried putting this same conditional statement inside of another content template just to decomplicate things. It still doesn't work. In the attached screenshots, you can see the conditional statement and just a paragraph with the word "books" if the condition is true. However, the actual output shows the debug info saying it's true but the word "books" does NOT appear in the output.
I've tried something similar on my own test site and it is working (screenshot, using WC dummy data).
I think to see why it's not working on your site we'll need access to it, if that's okay.
I will mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.
Can you also confirm the url of where we can see the problem.
*** 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.
To add to what's already been said, I tried modifying content template 25451 to conditionally show product components such as an "Add to Cart" button if the post being displayed is post_type = 'product'. The debugging shows the condition is evaluated true, yet none of the contents in the conditional block are displayed. Could this all have something to do with WooCommerce? Attached are a couple more screenshots for you.
Sorry for so many messages - I'll take a break after this one! I was able to get the conditional content to come up properly when adding a slash to the front of the post type so it only shows content if the post_type = '/product' - I'm not sure why the slash is necessary. However, none of the WooCommerce blocks show up. I've figured out that they will only come up if they are added directly in the archive. If they are contain in a nester content template, then they don't show up. Can you confirm this is by design? If so, I will take this out of the nested content template and just put it directly into the archive template itself. I was just trying to avoid needing to update content in multiple places, but I can live with it if need be.
I have not yet gone back and tested this on the original "books" issue, but I'm assuming it follows similar logic and that I'll need to put the formatting directly into the archive output as opposed to embedding a content template. I'll stand by until I hear more. Thanks again.
The problem is that you're checking against the parent category i.e Books. Our conditional isn't checking against the parent category but rather the category/term that is actually selected on the post.
Given that this post below has the term "Peak Oil Essential Books" selected. It won't validate the conditional that is checking for Books even though Peak Oil Essential Books is a child of books. To workaround this you will need to select Both Parent and Child categories if you're going to evaluate the post against the parent. enlace oculto
. However, none of the WooCommerce blocks show up. I've figured out that they will only come up if they are added directly in the archive. If they are contain in a nester content template, then they don't show up. Can you confirm this is by design?
I'm not sure what you're referring to by non-woocommerce blocks. Taking a look at the product page only the items you have in your content template are showing up. I need some clarification here.
Thanks,
Shane
El debate ‘[Cerrado] Nesting Content Template Inside Conditional Statement Inside a View’ está cerrado y no admite más respuestas.