1

I have two sections (both Channel type):

  • Releases
  • Movies

Releases have one Entries field type, the source is Movies

So, I want Auto-generate a Release title from Movies, like this: Titanic, Avatar, Toy Story

This works { movies.one().title } as a Title Format on the Releases Settings but display just the first movie: Titanic, the question is how can load all the entries titles? to get Titanic, Avatar, Toy Story as a title

I do a research and I get this: How can I set an entry title automatically, based on a related entry? but again that display only the first entry title.

1

Not sure if this can be done in the shorthand syntax, but you can do this using Twig for the dynamic title format. The key is to use map to turn an array of entries into an array of titles and then join them. Something like this should work:

{{ object.movies.all()|map(movie => movie.title)|join(', ')|default('No movies selected') }}

Also note the default filter, which is a nice fallback in case no entries are selected in your movie field.

1
  • 1
    It works!, the field is required but yes the default is a nice fallback. – user15280052 May 7 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.