I've created a simple, straightforward form via our forms feature (NutsAndBolts).
Normally I'd just create a text page for the form and then pick the form in the editor. However, in this case, visitors should only be able to see the form when they're logged in.
So I'm contemplating writing some XSLT code for the login functionality and then calling the form inside that code snippet.
My question to you guys is, how do I call a specific form within an XSLT file?
I've inherited the site and I'm still adapting to the setup. I'm going to say custom. Regardless, I wouldn't mind any input you might have regarding Courier/Umbraco Forms. Might be something there to at least guide me in the right direction.
Alright, so with Courier/Umbraco Forms you should be able to put a "Form picker" property on a document type (there's a Data Type with that name).
Then in your XSLT file you could do something like this (assuming the alias of the property is form):
<!-- Render a Form if a Member is logged in -->
<xsl:if test="umbraco.library:IsLoggedOn()">
<xsl:variable name="formGUID" select="$currentPage/form" />
<xsl:value-of select="umbraco.library:RenderMacroContent(concat('<?UMBRACO_MACRO macroAlias="umbracoContour.RenderForm" FormGuid="', $formGUID, ';" />'), $currentPage/@id)" disable-output-escaping="yes" />
</xsl:if>
Unfortunately there's not a data type by the name "Form picker" or anything similar.
What I'd done instead was to create a document type with a RichText Editor property and then, when creating the document in question, insert the NutsAndBolts Forms macro.
In the XSLT I'd written code very similar to what you've suggested (as shown below).
Unfortunately, the form doesn't render.
<xsl:variable name="form" select="$currentPage/profileForm" />
<xsl:choose>
<xsl:when test="umbraco.library:IsLoggedOn()">
<xsl:value-of select="$form" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
Her kommer notifikation om krav om login.
</xsl:otherwise>
</xsl:choose>
"profileForm" being the document type with the Richtext Editor property.
It was kind of a longshot, and unfortunately it didn't work.
Okay - that's not totally off, though... You could actually get that working...
If profileForm is a childpage of $currentPage and the RTE is bodyText and the form macro has been inserted in the RTE, then you can ask for the contents of bodyText, but pass it through the RenderMacroContent() extension to have it render any macros first:
I have a Forms tab at the bottom of the backend (along with Content, Media, Settings, Developer, etc.). When I click on the tab, the name NutsAndBolts Forms appears at the top.
That's as close as I can get to an actual name for the plugin that controls forms.
Calling Form Inside XSLT
Hullo,
I've created a simple, straightforward form via our forms feature (NutsAndBolts).
Normally I'd just create a text page for the form and then pick the form in the editor. However, in this case, visitors should only be able to see the form when they're logged in.
So I'm contemplating writing some XSLT code for the login functionality and then calling the form inside that code snippet.
My question to you guys is, how do I call a specific form within an XSLT file?
Thanks!
No one?
Hi Heine,
Are you using a custom forms solution, or are you asking for a way to do this with Courier/Umbraco Forms?
I'm pretty sure I've done something very similar using Courier in the past...
/Chriztian
I've inherited the site and I'm still adapting to the setup. I'm going to say custom. Regardless, I wouldn't mind any input you might have regarding Courier/Umbraco Forms. Might be something there to at least guide me in the right direction.
Alright, so with Courier/Umbraco Forms you should be able to put a "Form picker" property on a document type (there's a Data Type with that name).
Then in your XSLT file you could do something like this (assuming the alias of the property is form):
Hope that helps — otherwise, shout! :-)
/Chriztian
Unfortunately there's not a data type by the name "Form picker" or anything similar.
What I'd done instead was to create a document type with a RichText Editor property and then, when creating the document in question, insert the NutsAndBolts Forms macro.
In the XSLT I'd written code very similar to what you've suggested (as shown below).
Unfortunately, the form doesn't render.
"profileForm" being the document type with the Richtext Editor property.
It was kind of a longshot, and unfortunately it didn't work.
Okay - that's not totally off, though... You could actually get that working...
If
profileForm
is a childpage of$currentPage
and the RTE isbodyText
and the form macro has been inserted in the RTE, then you can ask for the contents ofbodyText
, but pass it through theRenderMacroContent()
extension to have it render any macros first:/Chriztian
(But it would of course be better to find out which Form plugin that's actually being used - where do you "build" the Form(s) for that site?)
I have a Forms tab at the bottom of the backend (along with Content, Media, Settings, Developer, etc.). When I click on the tab, the name NutsAndBolts Forms appears at the top.
That's as close as I can get to an actual name for the plugin that controls forms.
Also, I misspoke. "profileForm" is actually the property with the RTE. The document type is named "profile."
is working on a reply...