0

I have nodes in a view using a custom view mode (using Display Suite). I'm doing some AJAX stuff when the user clicks on a particular node, so I need to wrap the nodes in a custom URL, like somenode/nojs/(nid).

I feel like I should be able to do this in Views, since fields can link to the content. Is there a way to get the node to link to a custom URL?

1

I don't know if you can get the node link in a custom URL, but you can overwrite the output of the nid field.

Steps:

1. Add NID field

enter image description here

2. Hide field (this might change depending in your setup)

enter image description here

3. Go to the overwrite section and overwrite the NID output

enter image description here

4. The rest is up to you. You can display a field as a link and add the NID field as a replacemente pattern or use it as is.

0

I was able to do it in Display Suite using tokens.

EDIT:

For getting my node of a particular view mode to be clickable, I was able to set it in my node's display, in the view mode, and below the fields under "Custom Wrappers", I switched the "Add Link" box to "Tokens", and entered my URL with the [node:nid] token.

However, that just added an onClick handler to my node wrapper, so it wasn't useful for the purpose of making my node clickable for an AJAX callback. I had to do override my template file and works fine.

  • Can you expand this to explain how you added the token, etc, particularly if it is different than @redhatlab's answer. – mpdonadio Oct 18 '13 at 12:51
  • Yes, but to stay within the context of my AJAX-related question, I need to see if this is going to work. I see the method I chose adds an onClick() handler to the node div, instead of creating an a tag/href element. If this doesn't work, I may need to try redhatlab's answer. – vintorg Oct 18 '13 at 18:42

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.