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


15

Just change the More link path to the node/[nid] Add field nid to the views field and exclude from display. Make sure nid is above body field. Re-arrange the fields by clicking on select list next to field label and drag nid field to top of body field. It works ! Drupal l function while generating links will convert automatically to path alias blog/blog-...


14

You should use hook_node_insert in a custom module to run your code when the node is created. function hook_node_insert($node) { // To include @marcvangend's comment. if ($node->type == 'type') { // Run code here only for node of type 'type'. } // Run code here for all nodes... }


13

$text = token_replace('token example - [node:title]', array('node' => node_load(123)));


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

You certainly can. You need Entity and Entity Token (comes with Entity module) modules. Clear cache after enabling them. The referencing node info will be available to you. For the 'referencing' functionality, I use Entity Reference instead of Node Reference which will most probably be deprecated in the near future in favor of Entity Reference. (...


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


9

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


8

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


8

Using Drupal 7, modules can easily handle tokens similar to [node:author:name], where the part of the token after node:author is referring to a user token. Differently from the Token module for Drupal 6, the code that in Drupal 7 handles the tokens allows the creation of dynamic tokens. This is because on Drupal 7, modules implementing tokens can replace any ...


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


7

You'll want to have the Token filter module installed and configured in your text formats to use tokens in the node body.


7

As @kiamlaluno mentioned in the comment, neither the token API in core nor the token.module replaces tokens in node bodies. For that, you need a module like Token Filter.


7

I ended up using a module to create a custom formatter. Image URL Formatter http://drupal.org/project/image_url_formatter . It created a new formatter option called "Image URL," and I can use that as a token.


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

Create your own tokens! You could create a small module that implements the token hooks (D6, but D7 should be similar), like so: function YOURMODULE_token_list($type = 'all') { $list = array(); $list['smart-ip']['smart-ip-country-code'] = t("The Country code"); // ...etc return $list; } function YOURMODULE_token_values($type, $object = NULL, $...


6

There is a module that replace some tokens accepted from the Token module (or implemented using hook_token_info() and hook_tokens() in Drupal 7) in the body of a node, the Token Filter module. Token Filter is a very simple module to make token values available as an input filter. There is then the Token Node Tokens (TNT) module that allows to define new ...


6

I think a template preprocess would be fine for this, specifically hook_preprocess_image(): function MYTHEME_preprocess_image(&$vars) { // alt if (empty($vars['attributes']['alt'])) { $vars['attributes']['alt'] = DEFAULT_IMAGE_ALT; } // title if (empty($vars['attributes']['title'])) { $vars['attributes']['title'] = DEFAULT_IMAGE_TITLE;...


6

For multiple cardinality fields you can use a pattern like [node:field-name:1] (note the use of hyphens instead of underscores). This is an example of the tokens available for a field called field_profile_categories with multiple values: I think in your case the pattern should be: [node:field-restaurant-category:1] Although the comments in the token ...


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


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


6

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


5

Try the token_replace() function in the block preprocessor. Example: $node = menu_get_object(); // Get the current node if ($node) { $vars['elements']['#block']->subject = token_replace($vars['elements']['#block']->subject, array('node' => $node)); } Maybe you have to load the user too to have the user tokens available.


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


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