4

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 I use the %get token in a hidden field? And if so then what [key] value returns the full (pathauto) url? Webforms can only use %get[key] and %post[key] for non-authenticated users.

2

You can achieve this by using the %server token as the value of the hidden field. To be more precise http://%server[SERVER_NAME]%server[REQUEST_URI] should get you the full url (path alias is also preserved). For a complete list of options that can be used with the %server token check out the manual.

UPDATE:

The %server token only works for authenticated users since Webform version 2.8 due to potential security/privacy issues with some values. Since you only need the url in e-mails a better solution should actually be to put a appropriately themed version of <?php print url($_GET['q'], array('absolute' => TRUE)); ?> inside your copy of webform-mail.tpl.php file (or webform-mail-[node id here].tpl.php).

| improve this answer | |
  • 1
    Webforms can only use the %server token for authenticated users... Only admins are authenticated on this site. Reopened question. – Kirk Twist Feb 16 '12 at 3:23
  • @KirkTwist You're right. I managed to miss this important detail. Updated my answer accordingly. – Madis Feb 16 '12 at 19:56
2

You can simply use the yoursite.com/%get[q] this token is for drupal's special request parameter which holds the current path

| improve this answer | |
  • This is a great workaround for the previous issue of the %server token not working for anonymous visitors. Tested, works great. Thanks! – David Csonka May 8 '13 at 14:58
2

If you are working with Drupal 7 + Webform 7.x-3.18 you can add a Hidden field to your webform.

Then in the hidden type you can choose the option "Secure value (allows use of all tokens)"

This allows you to use all tokens types, like %server[SERVER_NAME] or %server[REQUEST_URI]

Tested with anonymous users and working fine.

| improve this answer | |
0

When I required token support for my webforms I used the webform patched module. It's the webform module already patched to support tokens. So you could use in your hidden field the token [current-page:url]. I have not tried this in a block webform but I do not see a reason it should not work.

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