Skip Navigation

[Resolved] Cannot apply CSS class to conditional blocks

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.

This topic contains 3 replies, has 2 voices.

Last updated by hernanL 1 year, 6 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2605875

Hi, it's just something I've noticed. It is not possible to apply CSS classes to conditional blocks. The natural thing is within the conditional block to have another container to sort the content, but it can be useful to have the ability to apply classes to the entire conditional set

Greetings

#2606113

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

To achieve such a thing you need to enable the legacy view and use that method:

- Go to "Toolset > Settings > General".
- Find the "Editing experience" section.
- Check the "Show both the legacy and Blocks interface and let me choose which to use for each item I build" checkbox.
- Reload the browser page.
- Go to the newly added "Toolset > Views" menu.
- There you will be able to edit the views.

For more information:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

Now you will have access to HTML code and you can use the conditional shortcode to add inside the class attribute of an HTML tag to change the class depending on the result of the conditional:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-conditional

Thank you.

#2606123
class on conditional.png

That's interesting to know, I just want to report a smaller or simpler problem in modern blocks

Classes that apply to that block don't work. I understand that it's something very specific and probably not that relevant to implement (since most are going to create a container inside anyway)

In my particular case, at some point I considered "marking" certain blocks in the loop that contain a certain condition and then apply display none to them by CSS. But there are other ways to get to that and I have already created a specific ticket for the problem I am facing.

Thank you so much

#2606133

My issue is resolved now. Thank you!