0

I have a field (title) in my View that I want to print in another views field template, using:

print ($fields["title"]->content);

However, when I use the above code, the field now prints twice. So I tried to Exclude it from the display in Views, but then my above print stopped working. How can I exclude the field, but still print it somewhere else??

Thanks for the help

P.S. I am referring to Views fields, not Content Type fields.

5
  • possible duplicate of Field prints twice, or not at all when added to template file
    – Darvanen
    Commented Mar 18, 2015 at 1:18
  • @Darvanen no, this is for Views, not Content Type displays :)
    – caustic
    Commented Mar 18, 2015 at 1:27
  • Ok, fair enough, what's the rest of the code in your field template file?
    – Darvanen
    Commented Mar 18, 2015 at 1:38
  • @Darvanen I want to include the title field in another view field template. So I have tried to print the title using the code above ^, but when I print I get double title, I just need the one, but when I set it to Exclude from display in Views neither shows up.
    – caustic
    Commented Mar 18, 2015 at 2:38
  • I have got a render content in the Views template, but when I remove it then all the fields disappear
    – caustic
    Commented Mar 18, 2015 at 2:41

1 Answer 1

0

Excluding the field from display empties the $field['name']->content, so that when the renderer gets to the default field template, there's nothing to print.

If you absolutely cannot achieve your intended result using tokens and Rewrite Output then I suggest you:

  • Do as you have already done to print the title in a different field's template
  • Create a field template for title that is empty

Your Answer

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

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