2

Finally hopping back into Craft to finish a large project, and am loving so many of the new features added! One thing I am using extensively is the Title Format feature. For one of my entry types, my Title Format field looks like so:

{songTitle} - {{ performedWith.entry.title }}

performedWith is the name of a field that links to an entry. I assumed I could do entry.title to pull the title from the linked entry, but it is simply showing up blank. Any ideas? Thanks!

4

Lindsey's answer is correct when outputting to a template, however, from within the title field of an Entry Type you would use the following:

{songTitle} - {performedWith.first.title}

entry is not needed, and only need single brackets.

  • Ahhh, "title format"... somehow I completely missed that! – Lindsey D Dec 31 '14 at 23:08
1

If performedWith is a simple relationship field to another entry, then try it like this:

{{ entry.performedWith.first.title }}

Then you're getting the title from the first entry listed in your performedWith field.

  • Thank you for the reply. It is indeed a simple relationship field, but even when using the first parameter, it is coming back blank. So it looks like: {songTitle} - The artist name should be listed after the -. – Jeremiah Dec 29 '14 at 20:51
  • Oops, caught a typo... Updated my answer, try that. – Lindsey D Dec 29 '14 at 20:54
  • Still no dice. :( – Jeremiah Dec 29 '14 at 20:56
  • Couple questions... Are you on a normal entry page? And do you have the site running in devMode? If the site is running in devMode, you can use {{ dump() }} to find out what your variables contain. – Lindsey D Dec 29 '14 at 21:06
  • Using dump, you should be able to determine that (1) entry is an EntryModel, (2) entry.performedWith is an ElementCriteriaModel, (3) entry.performedWith.first is another EntryModel, and (4) entry.performedWith.first.title is a string... specifically, the string which you are trying to display. If for some reason that's not the architecture of those fields (or if some other error is popping up), then simply being in devMode should shed a little light on the problem. – Lindsey D Dec 29 '14 at 21:09

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.