Send XSLT Transformed Email to emails stored in node properties
Hi,
We have a simple email sign up form which takes usual personal details, including a venue selection dropdown list.
We'd like the from to send these captured details onto the selected venue. Each venue exists as a node and has a property "venueEmailAddress" which contains their email address.
In the past with fixed forms we've justed used a variation the following code to detect which venue has been selected and then forward the email on:
We could do this again, but the site will grow and many more venues are st to be added, so we don't want to have to manually adjust this code for each new venue.
If we could just get the ID of the selected node (we're using a Prevalue Source) then we could grab the property value for "venueEmailAddress" and feed this into SendMail(). However I'm struggling to pull out the ID and can only seem to get the value (name) of each venue.
Does anyone have any suggestions? Perhaps I'm thinking about this all wrong.
Yeah that's the workflow but how are you inserting the form on your pages? Or maybe you are running an older Contour version (before v3) that only has the usercontrol macro
I should have just listened to you closely in the first place! When replacing the option value with either id or value, the value is saved in the database. When a different string is used, ie
<option value="@pv.Value (@pv.Id)"
all is well and you can then split the string as you suggested.
Send XSLT Transformed Email to emails stored in node properties
Hi,
We have a simple email sign up form which takes usual personal details, including a venue selection dropdown list.
We'd like the from to send these captured details onto the selected venue. Each venue exists as a node and has a property "venueEmailAddress" which contains their email address.
In the past with fixed forms we've justed used a variation the following code to detect which venue has been selected and then forward the email on:
We could do this again, but the site will grow and many more venues are st to be added, so we don't want to have to manually adjust this code for each new venue.
If we could just get the ID of the selected node (we're using a Prevalue Source) then we could grab the property value for "venueEmailAddress" and feed this into SendMail(). However I'm struggling to pull out the ID and can only seem to get the value (name) of each venue.
Does anyone have any suggestions? Perhaps I'm thinking about this all wrong.
Many thanks
Adam
Comment author was deleted
Hey Adam
Could you tell me if you are using the usercontrol or razor macro, depending on that I can give you some tips :)
Hi Tim,
Using XSLT running on the "form submitted" action within Contour.
Comment author was deleted
Yeah that's the workflow but how are you inserting the form on your pages? Or maybe you are running an older Contour version (before v3) that only has the usercontrol macro
As of yet none - I'm just testing atm ;-) but I'll be using the RazorRenderForm macro.
Happy to use either depending on what solution you have.
Comment author was deleted
Ok :) well the razor one offers more flexibility, will do some tests and get back to you with some advice :)
Excellent thanks Tim, appreciate it!
Comment author was deleted
Ok several ways to do this but think this will be easiest:
Update the dropdown view so it also includes the id in the value, maybe seperated with | (so it's easy to split afterwards)
Details on customizing the views can be found here http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Custom-Markup/
Now in you xslt that transforms the mail, fetch the id from the value (splitting on the | ) and use that id to fetch the node by id
http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-(1)
And from that you should be able to fetch the property you want
Make sense?
Perfect sense. Thanks Tim. I'll give this a go and let you know how I get on.
Comment author was deleted
Cool hope you get it working :)
OK here's where I am:
FieldType.DropDownList.cshtml under Umbraco>Plugins>umbracoContour>Views changed to:
which is outputting a nice ddl with the ID of the nodes as the option values:
<xsl:variable name="venueValue" select="$records//fields/child::* [caption = 'Venue']//value"/>
<xsl:variable name="node" select="umbraco.library:GetXmlNodeById($venueValue)" />
<!-- Output venue email address (test) -->
<xsl:value-of select="$node/venueEmailAddress"/>
<!-- TEST OUTPUT -->
<xsl:value-of select="$venueValue"/>
However when testing the the value is still the venue name (eg London, Bristol, Chester etc) and not the ID.
Have I missed a step or does the XSLT need to be adjusted?
I suppose the other question is, is it possible in XSLT to get the ID of a node by using the node name?
Tim.
I should have just listened to you closely in the first place! When replacing the option value with either id or value, the value is saved in the database. When a different string is used, ie
all is well and you can then split the string as you suggested.
Final code for others, if it helps:
Thanks for your assistance Tim. I just need to pull the email address into SendMail() now and I'm done!
Comment author was deleted
Great :)
is working on a reply...