1

I have a content type which contains a website field of type "link." I am creating a view that should have the title which links to the content for each piece of content, unless a link is provided in the website field - then the title should link there.

This is what I am currently trying:

  • title field is hidden
  • website field results rewritten so that [title] is the text and it is outputted as a link to [field_website-url].
  • website field no results are set to go to: [title]

However, this method is not working. It works when there is actually a website URL specified in the website field, but for all others, clicking on the titles links to ".com/link].

Any help figuring this out would be greatly appreciated!

1

The problem lies in trying to use the 'link to original content' in 'no results'.

Try putting the fields in this order with these formats:

  • Title - just plain text
  • Link to content - raw URL
  • Website field - raw URL

Then set Rewrite Results to <a href="[token for website]">[title]</a>

And set No Results Behaviour to <a href="[token for link raw URL]">[title]</a>

Note you'll have to find the right token for the links in the Replacement Patterns section that shows up when you tick 'Rewrite the output of this field'

Don't use 'Output this field as a link' or the link will apply to the No Results Behaviour as well, I think.

  • I tried this, and the rewrite results works, but the no results behavior still doesn't. I get "view">TITLE" (where title is the title) and the word "view" links to <sitename>.com/<a href – ashlinry Feb 18 '15 at 14:10
  • I figured it out! Instead of using link for the no results, I used <a href="/node/[nid]">[title]</a> and this works. Your response helped me figure this out though! – ashlinry Feb 18 '15 at 16:13

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.