Send form to different email address based on Querystring or XSLT
I have an 'application form' page for courses being offered on my website. This page gets passed a course node ID via a Querystring, which some XSLT on the page uses to look up and display that course's info. An example URL would be ".../apply.aspx?courseID=2480", which would display some info for node ID 2480.
I want to add a form to the page that will send an email to one of a few possible email addresses, determined by a value stored in the node that's referenced in the URL.
How can I set up a form, or multiple similar forms, so that the email address the form goes to is conditional?
The only way I can think of is to output a form for each possible email address on the page, and then use XSLT to create some JS or CSS to hide all but the correct form. There are currently only 3 possible emails, so this wouldn't be that horrible, but obviously it's still a messy way to do it.
Is there any better way to do this, preferably without venturing into custom control territory? If necessary, I can change things around to make this work, as long as I stick with a single application page.
1) Use contour to create a single form, assuming all forms have the same fields. Set up the form as usual, create a hidden field and set the default value to your querystring 'courseID' value. Then either: A) Create a custom contour workflow. You'll have access to all the form values, so you can take that node ID, use the Umbraco API to get the actual node, grab any property values from that and then fire off your email. or B) Post the contents to your own webservice and handle the generation and sending of an email there.
2) Don't use contour. Instead generate your form via an XSLT extension or a ASCX control. Submit the form to another page that contains logic (such as an ASCX control - which would even be the ASCX control that renders the form itself and just checks the postback status) - or use AJAX to post the details to a /base URL using the Umbraco Base API. Then you'll have access to all the form fields programatically and can get the umbraco node via the API using the node ID and fire off any/all emails you need to the right place.
Thanks for the suggestions; those seem like good options. I figured out a simpler, albeit less elegant way to do entirely with built-in Contour functionality, though. It won't be good for every scenario, but I thought I'd share the process, in case anyone is looking to do something similar:
-I created a Contour form set to send to one of the email addresses -I downloaded the form and uploaded it a couple times to create copies -I changed the 'To:' addresses until I had one form for each possible address -I created a new document type containing only a richtext editor, and set it to use a nearly blank template -I added one of these blank template pages for each of the forms, as child nodes of my application page -I inserted the correct Contour form into the richtext editor on each of the pages
And then the important part: -I wrote some XSLT for the application page to add an iframe into the page, and to set its source to the correct form page URL, based on information it looked up from the querystring
The iframe is an obvious drawback here, but it might also be possible to load the content with Javascript instead.
Send form to different email address based on Querystring or XSLT
I have an 'application form' page for courses being offered on my website. This page gets passed a course node ID via a Querystring, which some XSLT on the page uses to look up and display that course's info. An example URL would be ".../apply.aspx?courseID=2480", which would display some info for node ID 2480.
I want to add a form to the page that will send an email to one of a few possible email addresses, determined by a value stored in the node that's referenced in the URL.
How can I set up a form, or multiple similar forms, so that the email address the form goes to is conditional?
The only way I can think of is to output a form for each possible email address on the page, and then use XSLT to create some JS or CSS to hide all but the correct form. There are currently only 3 possible emails, so this wouldn't be that horrible, but obviously it's still a messy way to do it.
Is there any better way to do this, preferably without venturing into custom control territory? If necessary, I can change things around to make this work, as long as I stick with a single application page.
There are a couple of options here:
1) Use contour to create a single form, assuming all forms have the same fields.
Set up the form as usual, create a hidden field and set the default value to your querystring 'courseID' value.
Then either:
A) Create a custom contour workflow. You'll have access to all the form values, so you can take that node ID, use the Umbraco API to get the actual node, grab any property values from that and then fire off your email.
or
B) Post the contents to your own webservice and handle the generation and sending of an email there.
2) Don't use contour. Instead generate your form via an XSLT extension or a ASCX control.
Submit the form to another page that contains logic (such as an ASCX control - which would even be the ASCX control that renders the form itself and just checks the postback status) - or use AJAX to post the details to a /base URL using the Umbraco Base API.
Then you'll have access to all the form fields programatically and can get the umbraco node via the API using the node ID and fire off any/all emails you need to the right place.
Cheers,
Drew
Hi Drew,
Thanks for the suggestions; those seem like good options. I figured out a simpler, albeit less elegant way to do entirely with built-in Contour functionality, though. It won't be good for every scenario, but I thought I'd share the process, in case anyone is looking to do something similar:
-I created a Contour form set to send to one of the email addresses
-I downloaded the form and uploaded it a couple times to create copies
-I changed the 'To:' addresses until I had one form for each possible address
-I created a new document type containing only a richtext editor, and set it to use a nearly blank template
-I added one of these blank template pages for each of the forms, as child nodes of my application page
-I inserted the correct Contour form into the richtext editor on each of the pages
And then the important part:
-I wrote some XSLT for the application page to add an iframe into the page, and to set its source to the correct form page URL, based on information it looked up from the querystring
The iframe is an obvious drawback here, but it might also be possible to load the content with Javascript instead.
is working on a reply...