With Drupal 7's Display Suite module, you had the ability to set classes and other elemental things on the individual fields:
I was curious if there was anything like this in the works, either in core or in a contributed module. I poked around, but was unable to find anything.
Comments
Hey @kristin 👋
You cannot achieve this via the "Manage fields" page at the moment, but here's what you could give a go:
node/%
as context -> this will allow you to be placing the various fields as blocks.Would that work in your case, or are you looking to also apply attributes like
name=
? Please report back here.Yikes, no. That would be a rather cumbersome approach.
I just want to be able to add classes to various elements to make them into things like buttons, or change their wrappers at whim. I'd sooner do this with jquery over loading all individual fields into a layout - the content I am working with has ~30-40 individual fields. Thanks!
It is also possible to achieve this with custom field templates.
To do this, copy the field.tpl.php file (from the Backdrop CMS installation folder \core\modules\field\templates directory to the current theme folder) and change its name to something like this: field--field-name.tpl.php - where field-name is the machine name of the field and can be easily found by viewing the code of the page you want, as well as at admin/reports/fields.
Instructions on how to do this with more clarification are published in the comments at the top of the core field.tpl.php and also at
https://api.backdropcms.org/api/backdrop/core%21modules%21field%21templa...
In particular, you can add your own class in line 53 in the code of field--field-name.tpl.php and place the custom template in the folder of the current theme.
I have started on a port of the Display Suite module. It is still very much in progress so the features that you need may not be working yet.
https://github.com/backdrop-contrib/ds
That is helpful @hosef, thank you! The project I'm wrapping up will not be aided by this, but I will keep it in mind for the several upcoming Backdrop projects we have scheduled for this year, perhaps I can contribute some to that project. :)
The next release of Field Wrappers will allow you to specify a class for the outer wrapper in the field formatter display settings.
Fantastic, thank you for the follow-up Laryn!
Hope it's ok replying to an older post.
Just found this post. (It's worthwhile browsing and searching this Forum!)
I've been hoping for this very thing, but only ever looked for Display Suite and Field Formatter. This will save me a lot of css and sometimes frustration. Thanks to whomever added this function.