backdrop-issues
backdrop-issues copied to clipboard
[META]: Provide commonly used formatters for fields in core
We should provide more field formatters to cover the most common use-cases for the display of multiple values.
Suggestions include:
- Comma separated list
- HTML list
- Other?
In Drupal 6 you could choose to display taxonomy terms on a node as a comma separated list of links. In Drupal 7, the only way to achieve the same thing was to use the taxonomy formatter module.
I would love to see this common-use-case feature restored to backdrop.
Here's a summary of sorts for these requests:
- Apply this new formatter to any multi-valued field
- Allow separating items by a custom delimiter (e.g.
,
,;
,-
, etc.) - Allow formatting multi-valued fields as HTML lists (e.g.
<ul>
,<ol>
) - Allow specifying a different custom delimiter for the last two items (e.g.
&
)
Modules to use for inspiration:
- https://www.drupal.org/project/taxonomy_formatter (This module adds a new formatter that allows you to specify the element type, the wrapper type, classes for both, the separator used, and if they link to the term pages or not. This gives much more customizable layout options.)
- https://www.drupal.org/project/field_delimiter Field Delimiter provides an additional setting for field formatters, allowing multi-value fields to be displayed with a delimiter between the values.
- https://www.drupal.org/project/textformatter This module provides a field display formatter to render field values as HTML or comma-separated lists. This can currently be used on all core field types (text, long text, number, list, and taxonomy reference etc..) and some contributed fields. (see below).
Agreed that this would be good in core. This module also allows it in contrib for now: https://github.com/backdrop-contrib/textformatter
Even better! A module that allows it for all field types :) Selfishly adding milestone :)
I really want this feature, but with 2 weeks before code freeze and a fantastic contrib solution already, it's not a priority for 1.8. I'm going to bump the milestone to 1.9.
I used to have a custom "delimiter" formatter, that allow user to choose the delimiter (like a comma, br tag, ...), and a custom delimiter for the last element ( &, "and", ...) can share the code if needed.
I seem to have a PR for this, but I'm not sure what state it's in. Pushing here so I don't loose it...
Copying ideas from the other duplicate issue, it'd be great to also allow displaying multi-value fields as <ul>
or <ol>
as well.
So here's a summary of sorts for these requests:
- Apply this new formatter to any multi-valued field
- Allow separating items by a custom delimiter (e.g.
,
,;
,-
, etc.) - Allow formatting multi-valued fields as HTML lists (e.g.
<ul>
,<ol>
) - Allow specifying a different custom delimiter for the last two items (e.g.
&
)
Modules to use for inspiration:
- https://www.drupal.org/project/taxonomy_formatter
- https://www.drupal.org/project/field_delimiter
- https://www.drupal.org/project/textformatter
Modules already ported to Backdrop contrib:
- https://github.com/backdrop-contrib/textformatter
Feel free to copy this to the original post above if it's helpful, and to edit at will.
I keep needing this feature, and get grumpy when I need to add textformatter. Adding the milestone review tag to see if this might be a good issue to schedule for the next minor release.
Now that https://github.com/backdrop/backdrop/pull/2493 is in, I wonder if that changes how this might be implemented, or if what's in this PR is still the best path forward?
@jenlampton the PR is not linked anywhere.
Well, I tried to make a new PR from my branch but GitHub said there were no differences in the code. I'll need to make a new one.
Resuming work on https://github.com/backdrop/backdrop-issues/issues/316