Please note I can't remember how the caption is cased so it could be that you need to look for "yourName".
You can see what XML you get by using <xsl:copy-of select="$records" /> - A little trick is to write it out in a <textarea> and then copy the output into your prefered code editor to get a better idea of the context you're looking into. You can do it like this
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="xsl msxsl user umbraco.library">
<xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" cdata-section-elements="script style" indent="yes" encoding="utf-8"/>
<xsl:param name="records" />
<xsl:template match="/">
<p>Dear <xsl:value-of select="$records//fields/*[caption='YourName']//value"/>,</p>
<p>Thanks for your enquiry.</p>
<p>We will aim to get back to you soon.</p>
<p>Regards</p>
<p>CIEH</p>
</xsl:template>
If so did you try switching between uppercase and lowercase when writing "YourName" or "yourName" ?
I guess it's not possible to check the output using the <textarea> in this scenario since it's a pretty tedious process to make the change and test it.
If I remember correctly you will also need to copy overwrite the XSLT file in the media library everytime you make a change to it and test again.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="xsl msxsl user umbraco.library">
<xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" cdata-section-elements="script style" indent="yes" encoding="utf-8"/>
<xsl:param name="records" />
<xsl:template match="/">
<p>Dear <xsl:value-of select="$records//fields/*[caption='yourName']//value"/>,</p>
<p>Thanks for your enquiry.</p>
<p>We will aim to get back to you soon.</p>
<p>Regards</p>
<p>CIEH</p>
</xsl:template>
</xsl:stylesheet>
I've tried switching between uppercase and lowercase ('yourName', 'YourName') but nothing seems to work. I am overwriting the XSLT file in the media library every time.
Referencing form fields in XSLT
I'm new to XSLT and am trying to create a basic file to use on one of my forms so when a user submits they get a confirmation email.
I just want to pull in the user's name into that email but I can't figure out how to reference it. The field is {yourName}.
Can anyone help? Using Umbraco 7.7.6.
Thanks
Owen
Hi Owen
Can you share what your current XSLT looks like please? :-)
/Jan
Hi,
This is what I've got:
The {yourName} field in my form is the one I want to pull through to the email.
Hi Owen
If I remember correctly you should be able to write something like this
Please note I can't remember how the caption is cased so it could be that you need to look for "yourName".
You can see what XML you get by using
<xsl:copy-of select="$records" />
- A little trick is to write it out in a<textarea>
and then copy the output into your prefered code editor to get a better idea of the context you're looking into. You can do it like thisIf you need to render more advanced stuff at a later point then this little snippet from mr. XSLT aka Chriztian Steinmeier might come in handy for you https://gist.github.com/greystate/2cb2c1f9d2f8085b23e4
I hope this helps :-)
/Jan
Thanks for your help. Unfortunately this isn't working. Am I missing some other code? The email I get through is:
Dear {yourName},
Thanks for your enquiry.
We will aim to get back to you soon.
Regards
CIEH
Hi Owen
So your code looks like this now?
If so did you try switching between uppercase and lowercase when writing "YourName" or "yourName" ?
I guess it's not possible to check the output using the
<textarea>
in this scenario since it's a pretty tedious process to make the change and test it.If I remember correctly you will also need to copy overwrite the XSLT file in the media library everytime you make a change to it and test again.
/Jan
My code is:
I've tried switching between uppercase and lowercase ('yourName', 'YourName') but nothing seems to work. I am overwriting the XSLT file in the media library every time.
Hi Owen,
I think the below code format may help. Please give it a try.
Try NOT using the form field alias name & see if it works..
~Brita
Hi Brita,
It works! Using the field question rather than the alias pulls through the data. Hadn't thought about doing that.
Thank you so much!
Owen
is working on a reply...