Questions tagged [tokens]

Use it for questions related to the Token module, or a similar form of token replacement system. Don't use it for authentication tokens.

Filter by
Sorted by
Tagged with
24
votes
6answers
21k views

How to programmatically create a custom token in a module

How would you go about programmatically creating a token? I wish to add some custom tokens for my module.
1
vote
2answers
757 views

How to concatenate all token values of a list in a single field within a Rules loop?

I am attempting to send a list of uploaded files on a newly created node via email. In a content type, I have a File Field that allows unlimited values. Within Rules, I created a loop calling the ...
4
votes
3answers
8k views

Path alias tokens and node references

I'm trying to figure out if path aliases are even capable of what I'm trying to do, or if I need some other sort of module. I have a content type "project" and a content type "mockup". A "project" ...
5
votes
1answer
16k views

Pass query string to Webform text field

I have a webform (www.mysite.com/myform) ad I want to be able to pass a URL string to a text field in the webform when a user visits the page and submits it. For instance, the URL provided to "...
4
votes
1answer
211 views

Tokens causing incorrect text substitutions [closed]

I'm running Drupal 7 on Ubuntu 14.04 server, core and all modules up to date as of today (7th May). We have noticed today that zeros (0) are not displaying correctly in blocks that have a custom token....
3
votes
1answer
195 views

How to create a Rule to create a new entity of type Comment and a body with tokens?

Using drupal 7 and the Rules module, I'm trying to "create a new entity" of type comment. What it's strange, is that although all the other fields accept tokens, "the main body text" doesn't. Tokens ...
1
vote
2answers
1k views

Programmatically changing the global site name?

I'm making a multi-site setup using the same install and the same database, basing it off domains. I'm trying to programmatically alter the site_name variable so that it displays a different site name ...
15
votes
1answer
881 views

What's the difference between !, %, and @ in replacement tokens?

I'm using the Message module on Drupal 7. For Replacement tokens, the help text says: A comma-separated list of replacement tokens, e.g. %title or !url, of which the message text makes use of. ...
7
votes
2answers
10k views

How should I use token_replace()?

Could somebody give me an example of how to use token_replace()? I'm trying to write a custom PHP rule for the Rules module that will rewrite few fields of a new saved content, using the values from ...
3
votes
3answers
8k views

How to obtain a token based on a entity_reference field?

I have a node type A with a entity_reference field named "field_subnode" pointing to a node type B: A -> B I'm using pathauto, with the following patterns setted up: URL path for nodes of type A: ...
7
votes
3answers
13k views

Get image's URL as a token for use in Views' replacement pattern

I need to get an image's full URL path as a token that I can use as a replacement pattern in Views. I'm trying to have one thumbnail image link to a larger image. I have the larger image excluded ...
4
votes
4answers
5k views

User picture and name in user menu

I would like to achieve what Acquia did on https://dev.twitter.com/. When you sign in, you can see the user picture and the user name in the right end of the menu bar and that is what I need. I made ...
1
vote
1answer
4k views

Extend Drupal 6 “form_token” & “form_build_id”

I'm posting in my website by using command line. Below codes works just fine for me curl -b cookies.txt -d title="$(my-own-sed-command)" -d taxonomy%5Btags%5D%5B1%5D="$(my-own-sed-command)" -d ...
5
votes
2answers
6k views

How to use tokens in a node?

I added a new content type. How can I use tokens when editing a node of that content type? For example, if I put "Hello [user:name]", the page shows the following: As shown above, the "[user:name]" ...
4
votes
1answer
3k views

Create custom token Drupal 7

Creation of custom tokens / placeholder for Drupal 7. I searched many forums to get any help regarding the creation of custom tokens but I failed in getting a proper solution that's why I decided to ...
4
votes
2answers
3k views

Creating a contextual filter for a view based on month and day

I've created a content type that represents a past events. I've added an extra date-field to this content type that indicates the date of the event. I'm trying to create a calendar that groups events ...
4
votes
2answers
153 views

URL alias, tokens is replacing 0s and 1s with node and entity [duplicate]

Has anyone seen a case that url aliases or tokens end up replacing certain numbers in a url with the words node and entity. A UTC Timestamp in my url ended up replaced like this: ...
3
votes
1answer
711 views

Executing PHP code only once, when the node is created

I am using Drupal 7 with the Token module. I wrote PHP code using the token field that can satisfy loading a specific node, updating some field values, and saving the node (using node functions). ...
3
votes
1answer
2k views

What is the correct token for a multi value field?

Oke, so I have this multi value field in drupal 7 and I want to use it's values in a custom php snippet in the rules module. I found the Array Tokens module to generate an array of the values, but ...
2
votes
2answers
1k views

Why doesn't my token redirect to the previous url?

I thought I could use the following code: <a href="user/login?destination=<?php print token_replace('[current-page:url]'); ?>a link</a> to redirect users to the page they were on ...
-1
votes
2answers
1k views

Using node values in a custom token

I'm trying to create a custom token using the Custom Tokens module. The token should use (and modify) a node field value, but it not returning any value. I set the token to need node data and I am ...
8
votes
3answers
3k views

A large amount of Tokens slows down everything - Placeholder Tokens

had anyone of you had a problem with too large amount of tokens? Because of having few content types (~8) with bunch of fields (~5-10 each) Token module generates too big table with replacement tokens....
6
votes
1answer
4k views

Creating a token for the image field file path with node reference nid

Since there is not support for fields in Drupal 7 tokens, how do I create the code to replace a token in an image field file path? EDIT: First, this is with the Node Reference URL widget so the NID ...
6
votes
3answers
5k views

Tokens for multi-valued fields?

In D7, it seems the token for fields (e.g., [node:field_date]) just returns the rendering of the field. So if the field is multi-valued, this token returns all the values rendered together. However, I'...
6
votes
2answers
416 views

Which user does the Rules module execute as?

I've set up a rule which is triggered by "after saving a new user account". This rule simply sends an e-mail. The e-mail contains various tokens, one of them is the field [account:field_country]. I'...
5
votes
3answers
15k views

How to set the “Read More” link (in Rewrite Rules for Body field) to point to the node url instead of the title?

I have created the blog as a view in Drupal 7.14 site. On my main blog page, I want to show 5 trimmed versions of the posts. I have added the following fields for the main blog page view - Title, ...
5
votes
2answers
6k views

Using custom token in node body

I am trying to minimize my workload in the future by putting recycled content into tokens, so that I only have to update the token as opposed to updating each individual node that uses the same ...
4
votes
1answer
3k views

Effective use of tokens view mode?

Most probably because of the naming coincidence with the Token module, I cannot find any tutorial or reference as per how to effectively use the Tokens view mode that I can see in perhaps all entities ...
4
votes
3answers
6k views

What is best method for token replacement within node content?

I am a newbie and have scoured forums (including this one), books, and documentation but cannot find a clear answer to this: What is the best method (custom module? PHP within node content? other?) ...
3
votes
1answer
240 views

How to dynamically redirect user from /foo/X to /bar/X?

So far I did the following: I've installed Redirect and Token modules. I've applied the patch for Redirect module to support wildcards. I've applied the patch for Redirect module to implement ...
3
votes
1answer
195 views

How to add an ascending row number (using some token) in front of each row in Views?

I can't figure out how to make a soccer league table that would look like this: http://prntscr.com/8va7h7 This is how the table looks now: http://prntscr.com/8va8eu Everything works but I don't know ...
2
votes
2answers
184 views

How do I assign a role to a user after the user's email is confirmed?

I want to assign a role to a user after the user confirms his/her email. How do I do this?
2
votes
1answer
709 views

Token's available “Replacement patterns” nested table should only be displayed on-demand

The Token module provides hooks to other modules to serve their own tokens. Multiple modules that support Token integration can generate a really huge nested table tree when displaying the available ...
2
votes
2answers
1k views

Formatting output of token

I have Drupal Commerce, and it sends confirmation emails after product is sold. In those emails are tokens. I have token [commerce-order:created] and I'm interested if is there any conveniant way to ...
1
vote
1answer
3k views

How to use drupal_get_token() within custom user registration email

I'm in the process of writing a custom user registration module for Drupal 7. I currently have my own custom form which calls the function user_save within it's submit handler to create the new user ...
1
vote
1answer
231 views

How to find where are defined tokens for Redirect?

After enabling Token and Redirect modules, I've found at /admin/help/token that I can use Redirect tokens. For example: However, I've got the problem finding the place where and how these tokens are ...
1
vote
1answer
339 views

Pathauto tokens for taxonomy terms except root

Thanks to pathauto and tokens it is very easy to generate URLs with [node:field_product_category:entity:parents:join-path]/[node:field_product_category:entity]/[node:title] \o/ But … I would like to ...
1
vote
1answer
502 views

Custom formatter for a multi-valued field

I have a multi-valued image field and I'd like to use its delta value with the Custom Formatters module. What I want to do would be really simple with html+tokens if it were to work: <div id="cf"&...
1
vote
1answer
3k views

Token replacement pattern is not working [closed]

I am using Drupal 7, and I have a node reference field in my content type. I used a token replacement pattern for auto-titling the node, but the token referring the node reference is not working. (The ...
1
vote
1answer
2k views

Field that links to a path/url defined with Tokens, is it possible?

I would like to create a few fields in a content type that will link to certain paths defined with Tokens, in my particular case the node author uid. I am using a number of user related modules ...
1
vote
1answer
1k views

Show field label when using tokens in “Global Custom Text” field in Views?

How can I show the field label when using tokens in Global field in Views. To reproduce: In a view: 1) Add field: title-field and enable to "Create a label" with value "My title". 2) Add field: ...
1
vote
1answer
285 views

Token Replacements

What is the proper way to store token replacements in a variable? Or should i even bother and call them directly? Things like: $author_uid = [node:author:uid]; $name = [node:title]; $picture = [node:...
1
vote
1answer
396 views

How do I access the first value of a multiple value text field using replacement patters inside a rule?

For example, lets say I have a list of objects each stored as separate values of a text field. How would I access the individual values? I have tried using delta and I have tried using entity token ...
1
vote
1answer
1k views

Webform, creating customized directories for uploaded files

Newbie and my first question on here. I'm still learning Drupal. So apologies if I missed anything Here is my issue I am using Webform to create an upload page. The user enters an ID(text field) and ...
1
vote
1answer
3k views

Create hierarchical taxonomy url alias with token term:parents using a field other than term:name

Sorry, the title is a bit of a mouthful but I will attempt to clarify. I have a question about pathauto tokens to create a URL alias for a nested/hierarchical taxonomy. Specifically, I have a ...
1
vote
1answer
1k views

node:url token not returning clean (alias) URL

This is a follow-up question of: How to delay the execution of a rule for 5 minutes? When not delaying the action, the node:url token does not return the alias URL, but the URL with the token ID: ......
0
votes
3answers
453 views

Get content page field value

I have a content page contain three field. Number A: Number B and Total Number. During add content page, I fill up Number A: 20 and Number B: 30. How to let Total Number auto display 20 + 30 = 50?
0
votes
1answer
1k views

Do tokens work with Rules “Set a data value”?

I have a simple Rule created in which the action is that a particular entity is created (a node) and then another action is called to "Set a data value" of one of this node's field (a standard text ...
0
votes
1answer
660 views

Store token replacement values in the database rather than tokens themselves

Is there a way to store the token replacement values of tokens put in a form field in the database rather than the tokens themselves? I have a text field in a custom content type that has a token as ...
0
votes
1answer
75 views

how to make URL aliases of nodes created via form include node title of original page?

Say I have a content type called "X", and every node of Content type "X" has a form that will create content type "Y" How do I go about setting up the URL alias of content type "Y" so it will be ...