We have a webform in a block that lets anonymous visitors inquire about services that are relevant to the page they are currently on. Is there any way that the name or URL of the page they're on can be passed by the webform in the webform email?

I've searched extensively but can't find any conclusive results. Any help would be appreciated.

Comments

Enzomaticus’s picture

Found the solution - created a hidden field with the value %server[REQUEST_URI] and it passes the URL of the page nicely.

amfis’s picture

Does it work for anonymous users?

pvasili’s picture

No :(

change
webform.module

....
function _webform_filter_values($string, $node = NULL, $submission = NULL, $email = NULL, $strict = TRUE, $allow_anonymous = FALSE) {
  global $user;
  static $replacements;

+  if ($node == NULL) {
+     $node = menu_get_object();
+   }

  // Don't do any filtering if the string is empty.
  if (strlen(trim($string)) == 0) {
....

and then use a hidden field %nid or %title

Hitby’s picture

Thanks, This was very helpful. I wish it could be committed as without it webforms in a block are useless.

Hitby’s picture

I've updated webform and this no longer works :(

Any ideas of how to do it now?

waveer’s picture

I have the same problem.
I test the method

SOLVED
Posted by Enzomaticus on January 9, 2011 at 5:30pm
Found the solution - created a hidden field with the value %server[REQUEST_URI] and it passes the URL of the page nicely.

but the Email sent the webform page's url,don't sent the url of the page that webform block they are currently on.
I search at http://php.net/manual/en/reserved.variables.server.php
and I replace
%server[REQUEST_URI]
by
%server[HTTP_REFERER]
it works!
So I paste this at this page,hope can help someone like me.

c4antonio’s picture

it works!
thank you very much!

Stone Liu’s picture

Thank you for the great piece of solution you pasted. It couldn't be more right and saved me hours of further researching and frustration.

Couldn't thank you more waveer!

knalstaaf’s picture

The Webform Patched module takes care of this.

Anonymous’s picture

Thanks, this just worked for me too!

smallcoder’s picture

Thanks the %server[HTTP_REFERER] works a treat and also solves redirecting back to the referring page after submission.

Splendid - I owe someone a beer !