Copied to clipboard

Flag this post as spam?

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


  • bev0 39 posts 59 karma points
    Feb 11, 2010 @ 19:58
    bev0
    0

    how to call macro as a param in another macro ?

    have anyone out there ever tried to call a macro as a param in another macro ? i've look everywhere online but no luck, please help

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 11, 2010 @ 20:16
    Morten Christensen
    0

    I have never tried it, and don't quite understand why you would do it? If you share a usecase it might make more sense - otherwise you might want to rethink the logic.

    - Morten

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 11, 2010 @ 20:22
    Lee Kelleher
    0

    Hi bev0,

    Depending on how you've got your macro set-up, and how you are thinking of passing the other macro through as a parameter, then it should be possible.

    The scenario I tend to use is with the Macro Picker data-type.  If I use it on one of my doc-types with an alias of "macro", then in my XSLT, I can use the following:

    <xsl:value-of select="umbraco.library:RenderMacroContent(data[@alias='macro'], @id)" disable-output-escaping="yes" />

    That will render the macro.  But remember, (and this is important), this only works with XSLT macros, NOT .NET user-controls (ASCX).

    Good luck, Lee.

  • bev0 39 posts 59 karma points
    Feb 11, 2010 @ 20:23
    bev0
    0

    example:

    i have a macro return a list of windows:  <umbraco:macro windowtype="{another_macro_calls}" alias="window_list" runat="server" />

    you would think i should call the "another_macro_calls" in the window_list xslt file, but unfortunately, that sub macro is calling a user control. so to use the umbraco.library:rendermacro() function to call a macro which link to a user control, it refused to work.

    any help, suggestions, hints would gladly appreciated!

    thanks

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 11, 2010 @ 20:47
    Morten Christensen
    1

    How about creating an XSLT Extension of the functionality in your usercontrol, so you can use it from within your first XSLT..?

    Or if you need your usercontrol to do something with the list of windows why not get the list from the usercontrol?

    Maybe you can elaborate on what your usercontrol has to do with the list of windows?

  • bev0 39 posts 59 karma points
    Feb 11, 2010 @ 21:30
    bev0
    0

    in umbraco version 4, i saw the wiki has another way to provide params.

    <umbraco:macro alias="RenderProperties" pagevalue="[@requestValueKey]" runat="server"/>

    question is, what is @requestValueKey ? i cant find any example of anyone using this.  if you happened to do this once before, please give me some insight.

    also, i tried to declare an asp.net variable like:  <% dim lTest as string = '<umbraco:Item field="note" runat="server" />' %> but it kept return error Expression expected. have i missed something ? or is it even possible to declare a variable in asp.net, however, i know for sure i can do the same but in javascript inside a <script> table..... in a template.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Feb 12, 2010 @ 09:50
    Lee Kelleher
    0

    Hi bev0,

    The "[@requestValueKey]" is an advanced Macro parameter field value type.  The @ symbol-prefix is for items in the Request object (anything from Request.Form, Request.QueryString, etc).  There are other special Macro parameter field types for page property fields and cookie values. The documentation is here:

    http://our.umbraco.org/wiki/reference/templates/umbracomacro-element/macro-parameters/advanced-macro-parameter-syntax

     

    For your second problem, it's a simple misunderstanding of how server-side (Classic ASP) works with the ASP.NET Framework.  You can not assign server-controls to inline-code variables.  It's far too much to explain in this short forum post - you might want to invest in an ASP.NET book, or online tutorials.  Anyway, the simple answer to what you want to do would be like this:

    <% Dim lTest As String = umbraco.library.GetItem("note") %>

    (It's been a while since I've written any VB.NET, was really holding back putting a semi-colon on the end!!)

    Good luck, Lee.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 12, 2010 @ 09:53
    Dirk De Grave
    1

    Hi bev0,

    http://our.umbraco.org/wiki/reference/templates/umbracomacro-element/macro-parameters/advanced-macro-parameter-syntax

    [@requestValueKey] takes the querystring value for the key specified as requestValueKey and feeds this parameter to your macro (which its passed on to a xslt or user control.

    So, if you're browsing http://www.domain.com/my-page.aspx?page=1 and in the template of the document, you've added

    <umbraco:macro alias="RenderProperties" pagevalue="[@page]" runat="server"/>

    then the value "1" will be passed as value for the parameter pagevalue

     

    Does that make more sense now?

     

    Cheers,

    /Dirk

     

  • bev0 39 posts 59 karma points
    Mar 03, 2010 @ 22:13
    bev0
    0

    thank you everyone for taking your time and reply my questions, it certainly helped me quite a bit !

Please Sign in or register to post replies

Write your reply to:

Draft