Search code examples
asp.netsitecoreweb-forms-for-marketers

Sitecore Web Forms for Marketers - use current URL within email body


I am trying to build a 'Tell a Friend' form for my Sitecore site using Sitecore's Web Forms for Marketers module and would like to include the URL of the current page within the body of the email. I have set the save action of my form to 'Send Email Message' and was wondering if it would be possible to use some variable to represent the URL of the current page, but can't figure out how to do it.

I noticed that if you link to a page when editing the HTML editor for the email template, the source looks something like this:

<a href="~/link.aspx?_id=6EC4BE56AEE740E99E09EECB20F97EC4&amp;_z=z">Name of page</a>

...so perhaps it is possible to use some similar syntax to get the current context page?

I have also tried setting the save action of my form to 'Tell a Friend' but I can't see how to make this include any email content at all, let alone how to make the email include a link to the current page.

For reference I am using Sitecore 6.5.


Solution

  • I have an idea for this, but its more of a hack. Worth a shot:

    Since the Email Editor supports inserting hooks for the dynamic fields (refer to section 4.2.2 of the WFFM User Guide [PDF]), why don't you create a Single-Line Text field on the form, call it "Current Page" and apply a unique CSS class to it (e.g. .current-page)

    Using custom CSS, hide the .current-page element and using JavaScript, get the window.location.url and put its value into the .current-page input (the hidden SLT field).

    Now you can use the hook [Current Page] in your email body.

    Again, this is an untested idea, so I'm not sure if it will work.