Copied to clipboard

Flag this post as spam?

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


  • Eduardo 106 posts 130 karma points
    Oct 28, 2010 @ 09:01
    Eduardo
    0

    Xslt parameters

    Hi,

    I want to pass a parameter to a macro.

    I get the current user id, and I want this value to be passed to a macro for retrieving data related to the user.

    Thanks beforehand.

    Regards,
    Eduardo

  • Kim Andersen 1447 posts 2196 karma points MVP
    Oct 28, 2010 @ 09:15
    Kim Andersen
    0

    Hi Eduardo

    If you want to send a parameter through a macro and into XSLT you can go ahead and do it like this:

    <umbraco:Macro Alias="YourMacroAlias" runat="server" YourParamName="TheParamContent"></umbraco:Macro> 

    Then in your XSLT-file your can grab the value this way:

    <xsl:variable name="VariableName" select="macro/YourParamName/."></xsl:variable>

    Remember to declare the parameter in the developer section, on the macro where the param should be used.

    After this you should be able to use the variable with the content of the parameter :)

    /Kim A

  • Rik Helsen 670 posts 873 karma points
    Oct 28, 2010 @ 09:22
    Rik Helsen
    0

    If you mean the current member that is logged in in the frontend, it's already available to you, here is an example in the old (4.0) schema:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <div class="welcomebadge">
    <xsl:choose>
    <xsl:when test="umbraco.library:IsLoggedOn() = true()">
    <xsl:variable name="member" select="umbraco.library:GetCurrentMember()" />

    <span class="hello">Hello</span>
    <span class="username">
    <xsl:value-of select="$member/data [@alias = 'Voornaam']" />&nbsp; <xsl:value-of select="$member/data [@alias = 'Naam']" />,</span>
    </xsl:when>
    <xsl:otherwise>
    You are not logged in!!!
    <a href="/login">Login</a>
    </xsl:otherwise>
    </xsl:choose>
    </div>
    </xsl:template>

    </xsl:stylesheet>

    If you have a different scenario, please give some more information

  • Eduardo 106 posts 130 karma points
    Oct 28, 2010 @ 09:26
    Eduardo
    0

    Hi folks,

    I am going to test it now.

    Thank you for your answers.

    Regards,
    Eduardo

  • Eduardo 106 posts 130 karma points
    Oct 28, 2010 @ 09:29
    Eduardo
    0

    Hi,

    Perfect, it runs well.

    Thank you for your answers.

    Regards,
    Eduardo

Please Sign in or register to post replies

Write your reply to:

Draft