1

Can anyone please tell me how to get the NID of a node from the 7.x-1.7 version of the Token module?

I haven't used Token in a long while until now when I'm simply trying to include the NID in the file directory path of an image field.

As the following screen shot shows, I have no token representing the NID (there used to be quite a lot of current node tokens):

enter image description here

Help, please!

  • 1
    What is this being used for? Instead of checking under "Current Page", look under "Node". I believe the token, if my memory serves me, is "[node:nid]". – AndrewMRiv Aug 2 '17 at 21:32
  • Do you have a node context? If you are using this in a block (or other entity), it might be unaware of the rest of the page and as such does not have access to [node:*] tokens. – Neograph734 Aug 2 '17 at 21:53
  • There is no node context so [node:*] does not exist. – sisko Aug 2 '17 at 22:39
  • I assume you need to add the relationship 'node' to your view.Then you will be able to access the node token. – danuddara Aug 2 '17 at 22:50
  • 1
    [current-page:url:unaliased:args:value:1] will this work? drupal.org/node/1360922 – danuddara Aug 4 '17 at 1:39
3

[current-page:url:unaliased:args:value:1] is the way to get the node ID from the URL with the token module. Source.

Glad it helped you out sisko. Cheers! Thank you.

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