Problem/Motivation

The goal is to solve these issues, which currently is difficult for the reasons given.

  1. #3298225: Allow for additional submitted templates: can't add suggestions because the theme needs to have a base theme.
  2. #3268914: Add option/setting to change "Submitted" formatter date format: would need to duplicate a lot of code from TimestampFormatter.
  3. Simplify the template (see below): forced to copy username.html.twig.

Details

Core template (part of node.html.twig):

<footer>
      {{ author_picture }}
      <div{{ author_attributes }}>
        {% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
        {{ metadata }}
      </div>
    </footer>

This module template (submitted.html.twig)

<footer>
  {{ user_picture }}
  <div{{ author_attributes }}>
    {% if link_path -%}
      {% if date -%}
        {% trans %}Submitted by <a{{ attributes }}>{{ name }}{{ extra }}</a> on {{ date }}{% endtrans %}
      {%- else -%}
        {% trans %}Submitted by <a{{ attributes }}>{{ name }}{{ extra }}</a>{% endtrans %}
      {%- endif -%}
    {%- else -%}
      {% if date -%}
        {% trans %}Submitted by <span{{ attributes }}>{{ name }}{{ extra }}</span> on {{ date }}{% endtrans %}
      {%- else -%}
        {% trans %}Submitted by <span{{ attributes }}>{{ name }}{{ extra }}</span>{% endtrans %}
      {%- endif -%}
    {%- endif -%}
    {{ metadata }}
  </div>
</footer>

Proposed resolution

All 3 issues will become easy to solve if we change the design.

  • Currently SubmittedFormatter is taking the output elements of AuthorFormatter and inserting extra parts within them.
  • Instead SubmittedFormatter can create a 'parent' structure that has several child elements, one of which is AuthorFormatter, another is TimestampFormatter.

The code changes are pretty simple. However the changes aren't fully back-compatible:
Sites that have customised the submitted template will need to update their version.
The manage display configuration changes: previously the created field should be hidden, now it should be configured and the display settings are used to control display of the submitted date.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Version: 2.1.x-dev » 3.x-dev
Status: Active » Needs review
StatusFileSize
new13.19 KB

Status: Needs review » Needs work

The last submitted patch, 2: manage_display.improve-submitted.3344232-2.patch, failed testing. View results

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new14.73 KB
new1.43 KB

  • AdamPS committed b2dd78b9 on 3.x
    Issue #3344232 by AdamPS: Improvements to Submitted Formatter
    
adamps’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.