Copied to clipboard

Flag this post as spam?

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


  • Bert 128 posts 251 karma points
    Apr 15, 2009 @ 15:52
    Bert
    0

    Using functions in macro parameters

    Problem:
    I need to pass a url of a content item to a .net control.

    My not-working solution:
    * create control with public property
    * create macro with parameter (url, string)
    * create document type
    * add content picker to document type (urlID)
    * create template
    * add macro to template
    * give urlID to macro parameter

    now the problem is the urlID should be parsed to the url using umbraco.library:NiceUrl()

    Not-working code:



    Is it possible to convert the urlID in the template?
    I know I could do it in the code of the control as well, but I need an other way now.

    Can a library function be used inside a template like I try to do?

  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Apr 15, 2009 @ 16:57
    Douglas Robar
    0

    You CAN use simple library calls in a template using the xslt feature of the umbraco:Item tag.

    Here's how to do it...

    First, we'll just display the id to be sure it is being picked up properly. Then we'll add a bit of inline xslt to give us the nice url. To do this, put the following in your template (assuming the urlID is the docType property):
    [code][/code]

    The easy way to do this is to use the button on the toolbar when you're editing a template. Then you just select the field and you've got the umbraco:Item tag.

    When you view your website you should see the id displayed.

    Once you've got the id, we'll just add a bit of inline xslt (see this umbraco book for more details: [url]http://umbraco.org/documentation/books/inline-xslt[/url])

    [code][/code]

    Basically, it applies the xslt command and uses whatever is in the field="" and puts it into the xslt at the {0} placeholder.

    Hope that helps.

    cheers,
    doug.

  • Bert 128 posts 251 karma points
    Apr 15, 2009 @ 18:07
    Bert
    0

    First of all a big thanks. I got it to work this far.

    The second and final problem I now have is that I need to insert this formatted item value in the macro of my user control.

    [code][/code]

    Generates the correct output and should now be linked to the url parameter of the macro.

    [code]
    [/code]

    Once again thanks for the help so far. Greetings

    Bert

  • Bert 128 posts 251 karma points
    Apr 17, 2009 @ 10:34
    Bert
    0

    [code][/code]

    using library functions impossible as a parameter value for a macro inside a template?

  • Joey Kincer 43 posts 64 karma points
    Mar 13, 2010 @ 19:36
    Joey Kincer
    0

    Was this ever figured out? I'm having the same trouble trying to insert a URL (from Content Picker ID) into a Macro property.

  • Rik Helsen 670 posts 873 karma points
    Mar 18, 2010 @ 14:04
    Rik Helsen
    0

    Same issue here (i posted my thread here: passing a mediaitemurl to a macro as parameter (in a masterpage) - UI Questions - our.umbraco.org ) is there a solution at hand?

  • Brian Manning 22 posts 43 karma points
    Mar 23, 2010 @ 20:20
    Brian Manning
    0

    I was able to do something like this using:

    <umbraco:Macro Alias="SomeAlias" runat="server" PassValue="[#ValueInContentManager]"></umbraco:Macro>

    I think the problem above might have been

    url="umbraco.library:NiceUrl([#urlID)"

    Notice "#urlID" doesn't have a closing bracket "]" though I'm not sure if that's it because I wasn't doing exactly the same thing.

Please Sign in or register to post replies

Write your reply to:

Draft