soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Conditions for classes #2482

Open s-gundlach opened 3 years ago

s-gundlach commented 3 years ago

I would like to see a function where you make the assignment of classes to individual elements dependent on conditions. The classes are assigned in the usual way to the elements, in addition, one can set conditions for the corresponding classes on the individual elements, which determine when these classes are output in the frontend. These conditions work analogously to the existing conditions when displaying individual elements on the page.

To make the function as flexible as possible, the conditions are not set at class level, but can be set individually for each element.

In many web projects, it is common practice to assign additional classes to individual elements that may appear on multiple pages, depending on the page in question. For example, this could be classes like is--post, is--page or has--xyz etc. This function can be used even more versatile with the help of ACF fields or custom PHP functions.

For example, if you want to make a small change to the style of the page depending on an ACF field, you are currently forced to create multiple templates or duplicate individual elements or entire element groups and then provide them with conditions. With conditions on classes such "duplicates" will no longer be necessary and the backend including the structure of the elements on the page will be well-organized.

antic1pate commented 3 years ago

I just came here to suggest the same so +1

Would be great when doing the templating. Instead of messing up the whole view with duplicate items you could just create css classes and trigger them with conditions

One example would be a posts/pages template that has a wrap with css for full width and boxed. Then just creaate a checkbox custom field on your posts and pages to switch between them