We already allow hiding fields from display and also hiding their label (we also have these options available for fields in views), but what options does one have if they need to rewrite the output of a field?...
option 1: Write custom php code, having to mess with preprocess hooks and node or field-specific template files.
option 2: "Hack" their way trying to use css :before
/:after
pseudo-elements & the content:
property.
UX problems with these two options: - Need to create your own sub-theme if you are using core or contrib, otherwise your customizations will be lost with core/contrib updates. - Have to know how to code
...don't like or can't code? Views is your friend:
option 3: Create a view showing nodes of the content type that contains the field you need to rewrite, add all the fields you need to show, add a contextual filter for nid
, override the node/%
path with that view.
UX problems with this option:
- Try to change the display of a content type a long time after you've implemented this -> ...see that your changes do not work -> ...try to figure out why -> ...remember that you have a view that controls the display -> smack forehead
- Did you override the node/%
path with a view believing that filtering by content type would leave the rest of the content types alone? Ha, think again ...now you have to account for all content types in that view -> smack forehead again
So, how about we do any or both of these:
- In each field settings on the manage display form, add the same options that we have available in views for fields:
- adding custom css classes to the field, the label or the entire field wrapper
- changing the HTML element (tag) for the field, the label, or the entire field wrapper
- custom empty value text (for optional fields) + the option to not render if empty
- rewriting the output of fields using HTML, tokens and replacement patterns
- Allow a view to be used as a display mode of a content type. Related: #2433
PS: #2605
Recent comments
Correct, if you add multiple condition statements they are treated as AND so it would appear to the system as: node/103 AND node/91 which will never happen. Glad you found the way to...
Blocks (custom) not displaying in Harris sidebars with visibility condition set to more than one url path (node)
YES! That works. This whole thing is extremely bizarre, though. On the site I'm building (not the sandbox demo), I had a view that was displaying multiple images correctly (i.e. once, not...
Duplicated images in view
Maybe "Query settings" : "Distinct". If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it...
Duplicated images in view