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.
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. ...
12
votes
2answers
1k views

How to access values from earlier steps in multi-page Webform?

I'm using Webform 4. It uses Drupal's tokens, not it's own % tokens like it used to in version 3, and pretty much all what I found was about webform 3. Say I want to make multi-page subscription form....
10
votes
4answers
9k views

Using tokens in block titles

Plugging tokens into a block's title only shows the input text instead of what the token's supposed to output. Is there a way to enable/use tokens in block titles, or maybe an alternative method of ...
10
votes
1answer
4k views

Pass parameters with tokens

Is it possible to send parameters along with tokens? I have a module that defines the mod1_info and mod1_tokens. If I enter %token:mod1:test on a page, it is replaced with <a href='test.html'>&...
9
votes
3answers
5k views

Entity Tokens + Date Field + Custom Format… unable to use spaces

I have a content type (Question of the Week)... with a Date field (Used for "Publish Date". Questions won't be published until that date). I am trying to custom format the Title for it without ...
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....
8
votes
3answers
7k views

Set a token as the default value of a new field

In Drupal 7, you can set defaults values for most fields. Is it possible to set a token as the default value. I remember this being possible in Drupal 6, but it doesn't seem possible in Drupal 7. ...
7
votes
2answers
5k views

Format date in Rules

I'm using a rule to send out emails when a node is created. Under Action and Message body, I insert [node:field_calendar_date]. The token is replaced with (for example) "2012-12-14T08:00:00" in the ...
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 ...
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 ...
7
votes
1answer
5k views

“user:one-time-login-url” token not getting replaced by token_replace

I'm trying to send e-mails to users manually by using the hook_mail_alter hook. The following is my function in its entirety: function custom_module_mail_alter(&$message) { $email = '[user:...
7
votes
8answers
4k views

Rewrite CCK field output without using templates

The Views module has the nice option to rewrite the output of a field. This allows to adapt the output of CCK fields using Tokens without having to create a template for that view. Is there a module ...
6
votes
2answers
3k views

Adding a custom Token so i can use in Webforms

I am having the smart-ip module installed. It allows me to get User country, city etc very easily like this: echo $_SESSION['smart_ip']['location']['country_code']; I want to use this as a token ...
6
votes
1answer
2k views

How to use tokens in php code of the rules module?

I'm using Ajax_comments to add comments on nodes without having to reload the page on save. Now the "node history" doesn't get updated which throws off the "new comment" count. I tried to create a ...
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'...
6
votes
1answer
2k views

Token replacement pattern for triggered rules on node creation

I am currently using triggered rules to send notifications whenever a certain node type is created (by anonymous, unauthenticated users). In the email notification sent I would like to include some of ...
6
votes
1answer
1k views

An alternative for pathauto and token

I'm considering alternatives to pathauto module for automatic URL alias generation. The reasons I want to stop using it are the following: Most of the aliases are [node-type]/[node-title] so I do ...
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
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 ...
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 "...
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
1answer
3k views

Where is the the full tokens list for a site?

In the Metatag module UI it uses tokens but only shows a small list of tokens that are relative to the site information rather than the full content tokens which it can use, in D7 there was an admin ...
5
votes
1answer
1k views

Why are some place holders '@' and others '%'? [duplicate]

For example: watchdog('alerts', 'Message for %user was sent.', array('%user' => $user)); and drupal_set_message(t('options: @options', array('@options' => $form_state['values']))); Is there ...
5
votes
3answers
7k views

Can I display all token values available for my Drupal installation?

Is there a way that I can display all possible values for tokens available on my Drupal installation? For example, I'd like to see all of the possible values for the [termalias-raw] placeholder that I ...
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]" ...
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 ...
5
votes
3answers
4k views

Using Views “Rewrite the output of this field” tokens

I have a field which allows a user to upload 3 photos called field_prodshots. To any Views experts out there, is it possible to display just the first value of that field instead of all 3 while using "...
5
votes
3answers
2k views

Custom formatting of tokens for date fields

In D8.1, I have created a field called field_date and added it to a content type. I try to use pathauto to try to configure a URL pattern for the content type like type/year/title. But the token ...
5
votes
1answer
527 views

How are user.tokens.inc and other similar files included?

I notice that many core modules in Drupal 7 implement hook_token_info and hook_tokens in a hook.tokens.inc file, but I can't figure out how this file is included. Should I be doing the same with my ...
5
votes
2answers
5k views

D7 Webform tokens for user fields

In D6 we could configure a webform field to pull profile data by using a token like %profile[key] and assigning the user field to the form (Details here). How can we to something similar in D7 using ...
5
votes
2answers
2k views

Is there a list of file/image field subtokens?

Token browser does not show the options for file properties. [node:file-field:0:file:url] gets the url, but is there a list of all file options? Or is there a way to check it from sourcecode somehow? ...
5
votes
4answers
5k views

Site url token in view

Are there any way to get site's base URL value in a token within view to use in its header and field(s). My local developments is on drupal installation in a sub-directory while on server it is on a ...
5
votes
4answers
5k views

How to use token as a filter value in views

I'm looking for a solution that would allow me to use tokens in views filter values. For example, if I have text field 'my_custom_text' I would like to have a filter that would allow me to use 'Is ...
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" ...
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 ...
4
votes
3answers
2k views

How can i display tokens with html tags?

On assigning tokens(both custom and exisiting tokens) with values like $replacements[$original] = "<b>Hello</b>"; and then using that token either in full html or any other text format(...
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?) ...
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: ...
4
votes
4answers
4k views

Can Webforms include the URL they were submitted from in their emails?

I have a bunch of webforms in blocks on taxonomy pages. It would be helpful for the recipient of the resulting emails to know what taxonomy page the user was on at the time they wrote their query. Do ...
4
votes
1answer
1k views

Drupal 8 - Named anchors in menu

How can I add a menu link as /test#anchor and link to #anchor section on the test page? I need to add a menu item that links to specific section on the target page. Drupal 7 had menu tokens to ...
4
votes
3answers
506 views

How can I render a token within a token via rules mail action?

I want to send a node via rules. I can send it using the [node:body] token. However, I want to be able to use tokens in the actual node body as well. (Note: These are not global tokens) Think of it ...
4
votes
4answers
6k views

How do I get the token for a date field type to display as a custom format?

When adding content I entered a date which is February 2013 within a Date field type but it is displayed as raw data such as 2013-02-01T00:00:00 for the token that is listed as [node:...
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
1answer
1k views

Display all tokens programmatically? Trying to debug token

I'm trying to debug creating a token. How to programmatically create a custom token in a module shows me how to create them. Is there a way to display all available tokens? I'm trying to test if my ...
4
votes
1answer
9k views

Tokens available in views

I am trying to change the output in my view; the problem is that I cannot access the [URL] token to rewrite to <a href="[URL]">this is my link</a>. It seems I can only access the [title] ...
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
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....
4
votes
1answer
3k views

should I use str_replace() or is there a better drupal way for that?

Some background info: I'm Building a D7 module that also sends out a message to users of the site. I want the site maintainers to be able to define the message by using 'tokens' like this: $string = "...
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 ...

1
2 3 4 5
14