Problem/Motivation
The goal is to solve these issues, which currently is difficult for the reasons given.
- #3298225: Allow for additional submitted templates: can't add suggestions because the theme needs to have a base theme.
- #3268914: Add option/setting to change "Submitted" formatter date format: would need to duplicate a lot of code from
TimestampFormatter.
- 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
Comment #2
adamps commentedComment #4
adamps commentedComment #6
adamps commented