Hot answers tagged

26

You can set a default value for each field on your webform. The default value you would use would be For Webform v3 and under: %get[customer_name] For Webform v4+: [current-page:query:customer_name] To get a first and last name you could do something like: URL: http://mysite.com/myform?first_name=John&last_name=Doe First Name Default Value: %...


20

From the format_string() docs: @variable: Escaped to HTML using check_plain(). Use this as the default choice for anything displayed on a page on the site. %variable: Escaped to HTML and formatted using drupal_placeholder(), which makes it display as emphasized text. !variable: Inserted as is, with no sanitization or formatting. Only use this for text that ...


11

No need to hack, just add the following line to your settings.php file: $conf['image_allow_insecure_derivatives'] = TRUE; Source That will stop the itok parameter from being used. It's even been wrapped in a module if you don't fancy editing settings.php. Image Allow Insecure Derivatives Provides a user interface to allow Drupal to bypass the ...


10

I wanted to add a new token to the Site information section of tokens, called City name. This is how I did it in Drupal 7. /** * Implements hook_token_info(). */ function my_module_token_info() { // Add tokens. $site['city_name'] = array( 'name' => t('Token Name'), 'description' => t('Token Description'), ); return array( '...


10

You can use [node:field_calendar_date:custom:l, Fd, gia], if [node:field_calendar_date] is a date token. In that case, [node:field_calendar_date:custom] returns the date in the custom format listed after the following colon. The format string is the one accepted by date(). If you want to use the format set as short/medium/long format set in the Drupal date ...


10

Have a look into the function definition of the format_string() function which is used by the t() function: Each type of placeholder has a way in which this function intrepretes it: @variable: Escaped to HTML using check_plain(). Use this as the default choice for anything displayed on a page on the site. %variable: Escaped to HTML and formatted using ...


10

I see its one of those things that you once you know. Enable modules: Token Help (core) Navigate to the page: /admin/help/token.


8

OK, got it, it is not working even if I do not really understand the logic under the hood... Actually, the two blocking issues I had were the following: A date may be a range, therefore [node:field_date] cannot be considered as a date token. Install Entity API and enable the module "Entity tokens" to get access to the actual date value, Beware that for an ...


8

Try this one - $replacements[$original] = \Drupal\Core\Render\Markup::create("<b>Hello</b>"); Helpful links: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Markup.php/class/Markup/8.2.x http://www.drupaldump.com/drupal-8-how-have-custom-tokens-html-them-properly-replaced


7

Here is the answer. Lets say I've 4 fields in Webform  Label    -   Field Key First Name - first_name Last Name - last_name Phone Number - phone_number Message - message Here is the way to access them in template field For example if you want to display name as the combination of First Name and Last Name Name: %value[...


6

You can also add a separate 'Content:Link' field: Then select the text you want to display on the 'Readmore' link (you may select a fixed text, or a dynamic text [like nodetitle] when you rewrite the field results).


6

I think I'm following you...you want a way to invoke the tokens you've created outside of their natural context, so you can debug easily? If so, you can use the token_replace() function. As you're defining tokens that need a node object, you'll have to load an appropriate one up for the job: // Load the node. $node = node_load($appropriate_nid); // Prepare ...


6

They do it by way of hook_hook_info(): Defines one or more hooks that are exposed by a module. Normally hooks do not need to be explicitly defined. However, by declaring a hook explicitly, a module may define a "group" for it. Modules that implement a hook may then place their implementation in either $module.module or in $module.$group.inc. If ...


6

token.module has various examples, for example this: // Add the token tree UI. $form['email']['token_tree'] = array( '#theme' => 'token_tree_link', '#token_types' => array('user'), '#show_restricted' => TRUE, '#weight' => 90, ); This displays a link for tokens for the type user (and global tokens). You can also use the #...


5

For Drupal 8, example using the node object: You can put tokens in your module at mymodule.tokens.inc using hook_token_info() to register them and hook_tokens() for the the replacement data. If you want to create a custom token for an existing token type, such as for nodes, you'll need to put your token within the subarray within hook_token_info(). Refer ...


5

For Drupal 8 // We need to include the needed class for tokens. use Drupal\Core\Render\BubbleableMetadata; /** * Implements hook_token_info(). */ function modulename_token_info() { $info = array(); // Add any new tokens. $info['tokens']['customtokentype']['customtoken'] = t('Telling drupal that you define custom token'); // Return them. ...


5

Maybe you can try these module http://drupal.org/project/comment_notify Video tutorial http://drupalize.me/videos/notify-author-comments http://drupalize.me/videos/notify-comment-reply


5

Here's how I got mine to work: Switch to 'Data selection mode' which is not how the mail action launches by default: Select through the field sequence just like you already had with tokens! I noticed that the tokens are otherwise not available if you just use the direct input mode. Weird!


5

This is already handled in the Entityforms Notifications sub-module the way you are describing. There is a view mode called "Email". That view mode controls which fields show up in the email. This is done via a token in Rules. In Entityform 1.x this token is controlled via the Entityform module itself. In Entityform 2.x this is controlled via the ...


5

You can configure URL pathauto alias for taxonomy terms as : [term:vocabulary]/[term:parents:join-path]/[term:name] for creating url aliases for taxonomy taxonomy hierarchy. Explore more using replacement patterns for specific taxonomy terms. Please refer this image for url aliases configuration page


5

You need to install the token filter module for the token insert to work. Download the module. Configure the tokens you want to use by role or globaly. and add the filter in the Text Format: Then you can use the ckeditor plugin to add the token in the Fields that have this Text format, and thats all. I've just test and it works perfect.


5

:source you can understand as parent of that node when you get in touch with drupal translation you can easily understand what hierarchy this :source is referring to. as per above link: Translations are managed in sets of posts, which represent the same information in different languages. Only content types for which the administrator has explicitly ...


5

You need a text filter to replace tokens in fields. You can configure them in admin/config/content/formats. In drupal 7 you can install the needed text filter with: Token Filter But this will not be ported to drupal 8 in the same way as in drupal 7: Issue Token Filter in Drupal 8 As this is a very simple piece of code, there is an unofficial version for ...


5

Add/edit a menu link Enter /test#anchor in the "Link" field Save the link You're done, make tea :) Point being - fragments are accepted as part of the link in Drupal 8. One exception seems to be the home page; it doesn't work with the <front> token, nor /#anchor. The fragment isn't rendered in either case.


5

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


5

There's nothing out of the box (see this issue for the details). Implementing your own token isn't too tricky. I haven't had a chance to test this but I'm pretty sure it'll work: function MODULE_token_info_alter(&$info) { $info['tokens']['paragraph']['parent_entity'] = [ 'name' => 'Parent entity', 'description' => 'Parent entity of the ...


4

I came across this issue too and just used the Menu HTML module in conjunction with Menu Tokens. This very simple module adds a checkbox to the menu item edit form and allows the admin to add html to the menu item title. This way you can use [current-user:picture][current-user:name] and the users picture (avatar) will show.


4

In Drupal 7, the list is available at /admin/help/token Cheers.


4

This allows you to change the output of field tokens without disturbing the default display of the field. For example, you might want the Body field displayed as formatted text by default, but plain text whenever it is output as a token. Take a look at http://drupal.org/node/1299662 for an example of how to use.


4

Old, but I think: [node:IMAGEFIELD_TOKEN:file:url] would do it of in case of a multiple image field: [node:IMAGEFIELD_TOKEN:IMAGEFIELD_IDX:file:url] Where IMAGEFIELD_TOKEN is your image field token, like field-image, field-images, etc. IMAGEFIELD_IDX (for multiple fields) is your 0-based index. 0 for the first image, 1 for the second and so on.


Only top voted, non community-wiki answers of a minimum length are eligible