first redactor

 avatar
tommydalton
twig
a year ago
657 B
9
Indexable
{% 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 %}

Editor is loading...
Leave a Comment