3

I have a Resource content type that has a Title, Link or File Attachment. The first is required, the latter two are optional. The goal is for the administrator to create a new piece of content and link to either an internal (or external) page OR a PDF/Word file.

What I would like is have the Title be a link to either the page link or file location based on whichever is empty.

Right now, in the view, I have Title, Link and File Attachment fields exposed but hidden. The Title field has Rewrite Output enabled, but how do I set it to link to either a web page or file path based on the empty value for the field?

Inside Rewrite Output, I can add either [file_link] or [file_attachment], but this is not conditional.

1 Answer 1

5

From what I understand, either the "Link" OR the "File Attachment" fields will be filled in, but never both. If that is correct the solution is pretty simple.

You need to "Exclude from view" the title field.

Then, you need to Rewrite both the File Attachment and Link fields via the "Rewrite the output of this field" and put the [title] (or wahtever the field name is) in the rewrite field.

Then also for each of those 2 fields, check the "Output as link" and put the link field into the link path for the link, and put the file attachment field into the link path for the file attachment.

Now you only need to open the "No Results Behavior" fieldset for each of those fields and check "Hide if Empty" and "Hide rewriting if empty".

Now either one or the other will be output with the title as a link to either the page or the file attachment depending on what you filled in on the node edit screen.

1
  • If it is possible for both fields to be filled in, there will be two links. @Jason, can you say whether this is a possibility?
    – ankles
    Commented Aug 15, 2014 at 15:10

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.