Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Heine Stick 12 posts 92 karma points
    Jan 11, 2016 @ 10:37
    Heine Stick
    0

    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!

  • Heine Stick 12 posts 92 karma points
    Jan 13, 2016 @ 10:18
    Heine Stick
    0

    No one?

  • Chriztian Steinmeier 2732 posts 8341 karma points MVP 5x admin c-trib
    Jan 13, 2016 @ 10:25
    Chriztian Steinmeier
    0

    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

  • Heine Stick 12 posts 92 karma points
    Jan 13, 2016 @ 10:36
    Heine Stick
    0

    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.

  • Chriztian Steinmeier 2732 posts 8341 karma points MVP 5x admin c-trib
    Jan 13, 2016 @ 10:49
    Chriztian Steinmeier
    0

    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('&lt;?UMBRACO_MACRO macroAlias=&quot;umbracoContour.RenderForm&quot; FormGuid=&quot', $formGUID, ';&quot; /&gt;'), $currentPage/@id)" disable-output-escaping="yes" />
    </xsl:if>
    

    Hope that helps — otherwise, shout! :-)

    /Chriztian

  • Heine Stick 12 posts 92 karma points
    Jan 13, 2016 @ 11:02
    Heine Stick
    0

    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.

  • Chriztian Steinmeier 2732 posts 8341 karma points MVP 5x admin c-trib
    Jan 13, 2016 @ 11:17
    Chriztian Steinmeier
    0

    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:

    <xsl:value-of select="umbraco.library:RenderMacroContent($form/bodyText, $currentPage/@id)" disable-output-escaping="yes" />
    

    /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?)

  • Heine Stick 12 posts 92 karma points
    Jan 13, 2016 @ 11:25
    Heine Stick
    0

    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.

  • Heine Stick 12 posts 92 karma points
    Jan 13, 2016 @ 11:40
    Heine Stick
    0

    Also, I misspoke. "profileForm" is actually the property with the RTE. The document type is named "profile."

Please Sign in or register to post replies

Write your reply to:

Draft