Copied to clipboard

Flag this post as spam?

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


  • Mouhot 9 posts 29 karma points
    Jul 23, 2010 @ 12:10
    Mouhot
    0

    Dynamic parameter to macro

    Hi

    I need to pass a dynamic parameter to macro.

    Is it possible without creating a usercontrol ?

    look :

    <umbraco:Macro idNode="1268" Alias="WBNTDisplayContactName" runat="server"></umbraco:Macro>

    this is working but idNode must be dynamic

    Basically I am looking for something like that :

    <umbraco:Macro idNode="{./data[@alias = 'ContactProjet']}" Alias="WBNTDisplayContactName" runat="server"></umbraco:Macro

    How can I do that ?

    cheers !

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 23, 2010 @ 12:20
    Sebastiaan Janssen
    0

    I'm assuming you macro is an XSLT file. So you could just solve this in your XSLT:

    <xsl:variable name="idNode" value="$currentPage/data[@alias = 'ContactProject']" />

    And then you can just refer to the idNode everywhere like so:

    <xsl:value-of select="$idNode" />

     

  • Mouhot 9 posts 29 karma points
    Jul 23, 2010 @ 12:28
    Mouhot
    0

    thanks !

    It works.

    But i thought it would be better to use a parameter if I want to re-use my template. If the node name (here the "id") is called something different in another XML input file it won't work anymore.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 23, 2010 @ 12:39
    Dirk De Grave
    1

    Hi,

    Can use

    <umbraco:Macro idNode="[#ContactProject]" Alias="WBNTDisplayContactName" runat="server"></umbraco:Macro>

    to pass the value of the property on the current document to xslt or user control

     

    Hope this helps.

    Regards,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 23, 2010 @ 12:44
    Dirk De Grave
    0

    And here's the wiki reference...http://our.umbraco.org/wiki/reference/templates/umbracomacro-element

     

    Cheers,

    /Dirk

  • Mouhot 9 posts 29 karma points
    Jul 23, 2010 @ 13:46
    Mouhot
    0

    hey.

    I tried this way the first time but I didn't manage to make it work.

    Thanks to you it now works with the parameter.

    cheers anyway

Please Sign in or register to post replies

Write your reply to:

Draft