backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

[META]: Provide commonly used formatters for fields in core

Open jenlampton opened this issue 7 years ago • 10 comments

We should provide more field formatters to cover the most common use-cases for the display of multiple values.

Suggestions include:

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).

jenlampton avatar May 07 '17 02:05 jenlampton

Agreed that this would be good in core. This module also allows it in contrib for now: https://github.com/backdrop-contrib/textformatter

laryn avatar May 07 '17 12:05 laryn

Even better! A module that allows it for all field types :) Selfishly adding milestone :)

jenlampton avatar May 11 '17 21:05 jenlampton

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.

jenlampton avatar Aug 18 '17 00:08 jenlampton

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.

opi avatar Jan 05 '18 18:01 opi

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...

jenlampton avatar Jan 16 '18 01:01 jenlampton

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.

ghost avatar Jan 18 '18 21:01 ghost

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.

jenlampton avatar Jan 02 '19 06:01 jenlampton

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 avatar May 03 '19 18:05 jenlampton

@jenlampton the PR is not linked anywhere.

klonos avatar May 03 '19 19:05 klonos

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.

jenlampton avatar May 03 '19 20:05 jenlampton

Resuming work on https://github.com/backdrop/backdrop-issues/issues/316

jenlampton avatar Apr 26 '24 23:04 jenlampton