6

How would you setup a section's entry type to auto-generate the titles based on the title (or slug) of another entry?

For example, we have a Software section with entries. We also have a Releases section. Each release entry has a related software entry, along with a versionNumber text field.

Ideally each release's title would be of the form :

{software.title} {versionNumber}

Where {software.title} is the title from associated entry.

Title Format input example

We've looked at all sorts of combinations to get that value out, but any usage seems to either be ignored or throw an error on publish.

2 Answers 2

10

You can access the Software entry’s title exactly the same way you would in your front-end templates: software.first.title. The only difference is the single-brace tags syntax, which you don’t even have to use if you don’t want to. Both of these are identical:

  • {software.first.title}
  • {{ object.software.first.title }}
3
  • How would you loop through a category field if it has multiple selections in a tree and you want them all to be in a title? No syntax I try works. Sep 11, 2014 at 14:32
  • @AlanMiller Not sure I’m following. Probably worth posting a new question. Sep 11, 2014 at 16:45
  • I asked my question here, thanks! Multiple category output in auto generated Sep 11, 2014 at 17:22
0

The "Inherit Title" plugin might work for you but you will have to test it for your needs. It hides the title field and then uses the content of other fields in the entry to automatically generate the title for you.

https://github.com/rkingon/Craft-Plugin--Inherit-Title/

From the read.me:

Say you have a "firstName" and "lastName" field, and you would like the Title to auto populate with "firstName lastName" you could use: "{{firstName}} {{lastName}}" as your settings configuration.

2
  • The option to use an auto-generated title is now a native option. It sounds like it has all the same options, but specifically the issue is with using Entry type content within the field. Jun 12, 2014 at 9:50
  • Hey, thanks for that, I had no idea. Brandon and the crew are on such a rapid development cycle, it is hard to keep up with all the new features (not a bad problem to have) :) Jun 12, 2014 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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