Copied to clipboard

Flag this post as spam?

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


  • Bob McLane 19 posts 39 karma points
    Apr 13, 2011 @ 13:58
    Bob McLane
    0

    Problem with returning value of a XSLT Macro

    I have a macro that is returning the path of an image. I'm trying to use that path inside a div tag. This is probably pretty simple but my HTML skills aren't cutting it. Hope someone can help!

    Here's my HTML tag with the macro embedded:

    <div class="bg-content-location" style="background:url(<umbraco:Macro source=[#imageFileNamePicker] Alias="RPCEmbeddedImage" runat="server"></umbraco:Macro>) no-repeat 408px 100%;">

    I've confirmed by just inserting the macro by itself in the HTML that it does return the correct path to the image. However when I try to embed the macro in the <div> tag it just displays the syntax for the macro in the html.

    From the source of the published page:

    <div class="bg-content-location" style="background:url("<umbraco:Macro source=[#imageFileNamePicker] Alias="RPCEmbeddedImage" runat="server"></umbraco:Macro>") no-repeat 408px 100%;">

     

    I'm using v4.5 and thanks for the help!

  • Seth Niemuth 275 posts 397 karma points
    Apr 13, 2011 @ 14:21
    Seth Niemuth
    0

    Do you not need quotes around the source?

    <div class="bg-content-location" style="background:url(<umbraco:Macro source="[#imageFileNamePicker]" Alias="RPCEmbeddedImage" runat="server"></umbraco:Macro>) no-repeat 408px 100%;">

  • Bob McLane 19 posts 39 karma points
    Apr 13, 2011 @ 14:25
    Bob McLane
    0

    Thanks, Just tried that and all it did was add quotes in the rendered html.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Apr 13, 2011 @ 14:56
    Dirk De Grave
    0

    And what if you use single quotes in your style attribute, cause now the style attribute gets ended by the first double quote on source attribute of your macro.

    Alternatively, you could move the div to the xslt (assuming it's a xlst being referenced by the macro) or, pass some extra parameters onto the macro (for your div's class for example.

     

    Cheers,

    /Dirk

  • Bob McLane 19 posts 39 karma points
    Apr 13, 2011 @ 15:08
    Bob McLane
    0

    The single quotes on the style attribute took care of the issue! Thanks!

    The template HTML now looks like this and works .....

    <div class="bg-content-location" style='background:url(<umbraco:Macro source=[#imageFileNamePicker] Alias=RPCEmbeddedImage runat="server"></umbraco:Macro>) no-repeat 408px 100%;'>

     

Please Sign in or register to post replies

Write your reply to:

Draft