This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

microcipcip12128
microcipcip12128

Given this code, is it possible to change the first or last item in the list? I mean with something like {% if first %}first!{% endif%} {% if last %}last!{% endif%}?

{repeater name="content_sections" prompt="Add another content section"}
    <h2>{text name="title" label="Title"}Title{/text}</h2>
    <p>{textarea name="content" label="Content"}Content{/textarea}</p>
{/repeater}

Last updated

oliver.lawrenz57176
oliver.lawrenz57176

It's much to late to help, but for people stumbling across this. Here the solution.

Use Twig syntax loop.first and loop.last


{repeater name="content_sections" prompt="Add another content section"}
    {% if loop.first%}first!{% endif %}
    {% if loop.last%}last!{% endif %}
    <h2>{text name="title" label="Title"}Title{/text}</h2>
    <p>{textarea name="content" label="Content"}Content{/textarea}</p>
{/repeater}

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.