Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show headlines in article teasers again #7026

Merged
merged 6 commits into from Mar 20, 2024

Conversation

zoglo
Copy link
Contributor

@zoglo zoglo commented Mar 18, 2024

Fixes #7025

@leofeyer leofeyer added this to the 5.3 milestone Mar 18, 2024
@leofeyer leofeyer requested a review from m-vo March 18, 2024 14:51
@ausi
Copy link
Member

ausi commented Mar 18, 2024

Block has to be moved into the content

But this is not the case with all the other templates I think.

Can we instead just set the headline variable to the expected value?

{% set headline = { tag_name: 'h1', text: article.title } %}

@zoglo
Copy link
Contributor Author

zoglo commented Mar 18, 2024

Block has to be moved into the content

But this is not the case with all the other templates I think.

Can we instead just set the headline variable to the expected value?

{% set headline = { tag_name: 'h1', text: article.title } %}

It's not the case because this template renders the headline based on the article title and doesn't work like all the other content elements.

If it would have worked, it would have thrown an error due to text not existing :)

@m-vo
Copy link
Member

m-vo commented Mar 20, 2024

IMHO the correct fix is to add {% set headline = {tag_name: 'h1', text: article.title} %} outside of the content block and remove the headline block. Adding the line changed the outcome in the tests as expected for me.

@zoglo
Copy link
Contributor Author

zoglo commented Mar 20, 2024

@m-vo @ausi I was confused about your approach first but you are totally right.

However, changing it to

{% trans_default_domain "contao_default" %}
{% extends "@Contao/content_element/_base.html.twig" %}
{% use "@Contao/component/_read_more.html.twig" %}

{% set headline = {tag_name: 'h1', text: article.title} %}

{% block content %}
    {% block teaser %}
        {{ article.teaser|default|insert_tag|raw }}
    {% endblock %}

    {% block link %}
        {% with {title: 'MSC.readMore'|trans([article.title])} %}
            {{ block('read_more_component') }}
        {% endwith %}
    {% endblock %}
{% endblock %}

also needs the updated tests in a5febfd because previously it didn't test the headline at all.

@leofeyer leofeyer linked an issue Mar 20, 2024 that may be closed by this pull request
@leofeyer leofeyer changed the title Display headline within article teaser again Show headlines in article teasers again Mar 20, 2024
@leofeyer leofeyer merged commit 8447f7a into contao:5.3 Mar 20, 2024
16 of 17 checks passed
@leofeyer
Copy link
Member

Thank you @zoglo.

@leofeyer leofeyer added bug and removed feature labels Mar 21, 2024
@zoglo zoglo deleted the bugfix/article-teaser-headline branch March 25, 2024 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Headline within article-teaser is not shown
4 participants