first redactor

 avatar
tommydalton
twig
a month ago
657 B
2
Indexable
Never
{% set foundRedactorContent = false %}

{# Loop through all the fields in the entry #}
{% for fieldHandle, field in entry.getFieldLayout().getFields() %}
    {# Check if the field is a Redactor field #}
    {% if field.className() is same as('craft\\redactor\\Field') and not foundRedactorContent %}
        {# Output the field's content and mark that a Redactor field has been found #}
        {{ entry[fieldHandle].getParsedContent()|raw }}
        {% set foundRedactorContent = true %}
    {% endif %}
{% endfor %}

{# Fallback message if no Redactor field is found #}
{% if not foundRedactorContent %}
    <p>No Redactor content found.</p>
{% endif %}

Leave a Comment