0

Nodes of content type A are attached to nodes of content type B with an entity reference. Im listing Nodes of type A on Node B with a view.

Now I need the list of Node As to be links if their node's body has content. If their node's body doesnt have content then I need it to not be a link.

  • Im not following, are you displaying a list of nodes (A) as plain text? If so you need to select 'link to content' for that field. – Alex Gill May 21 '13 at 10:42
  • I need the list of Node A's to be links unless the node doesnt have content in its body field, in which case I need it to be plain text (not a link). – Evanss May 21 '13 at 12:01
  • 1
    In broad strokes, I'd use a views field template for this. Put the body in another field and set it to not be displayed, then, in this field template, check if it is empty, and if so, just output the title, otherwise, output a link to the node. – Jimajamma May 21 '13 at 13:45
1

This can be done in Views with no PHP or templating.

Add 2 title fields, one that is a link to the content and one that isnt.

Exclude both fields from display.

Add a body field and rewrite the output of the field. Use a replacement pattern thats the node title which is a link.

Under no results behavior add the token thats the node title which isnt a link. Make sure 'Hide rewriting if empty' is not checked.

| improve this answer | |

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.