0

I have a content type that has an External Link (field type: Link) which is an optional field. So users can either type in a url or not. I've created a View where I want to show the latest 2 content types.

I want to be able to display the nodes where its Title either links to the External Link or the url of the content. I already have Views Conditional enabled but I dont think Im setting it up correctly because the nodes arent using the proper url. The url is "http://localhost.test:8888/[path]. The 2nd node is correct though, it has http://yahoo.ca which is the External Link that I used.

Views Fields settings

Views Conditional settings

If anyone has any clue why the settings arent correct, please let me know why. THanks.

  • I find it easier to achieve this title links to external URL (if there) or local site url if not there using a custom View Field Template and a php preprocessor function. Trying to do this in the Views Admin UI is a nightmare. – tenken Sep 8 '14 at 15:54
1

If I correctly understand your point, you would like a view to display two latest nodes of a specific content type. While displaying these nodes the view should check:

  1. External link is provided or not

If External link is provided then output that as a field of view, if External link is not provided then output the URL Path of the content.

I can achieve this with just Views without the need of the Conditional one, unless I am misunderstanding your questions. I have the following steps for you to achieve what I stated here,

  1. Create a content type with link field and either Pathauto or custom URL supplied
  2. Create a view with content type as the one created
  3. Choose Field for Format Show and the select whichever field of the content type you are interested including the External Link & Path fields
  4. Click on the external field link, once opened change the title to New Title or whatever fancy
  5. You would need to use the NO RESULT BEHAVIOR settings of this field
  6. In NO RESULT BEHAVIOR supply the placeholder for PATH which is [path] - The path should be included among the fields
  7. Save and there you go the result, if the node is not having an External link then it will display the path as value of external field, otherwise it preserves the supplied external URL. Screenshot for more detail

Create content types as follow: enter image description here Configure view as follow enter image description here Configure the NO RESULT BEHAVIOUR as follow enter image description here There you go the result of your view, first content types does not have external URL and the second content types does have (don't forget to include the path as one of the fields or you won't be able to access it) enter image description here

| 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.