Copied to clipboard

Flag this post as spam?

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


  • Matthew 93 posts 153 karma points
    Jun 13, 2012 @ 00:11
    Matthew
    0

    another passing parameters question

    I have a page with ~15 images, each in a property: fig1; fig2; fig3; etc. I'm trying to create a macro with a parameter so I can just change the figure property for each instance I place on the template.

    This razor script with no parameter works:

    Template:
    <umbraco:Macro Alias="ShowFigure" runat="server"></umbraco:Macro>

    Script:
    <a href="@Library.MediaById(Model.fig1).umbracoFile">
    <img src="/imagegen.ashx?width=550&[email protected](Model.fig1).umbracoFile" alt="" />
    </a>

    If I add a text parameter 'figure' to the macro, and input 'fig1' when inserting the macro into the template, plus replace 'fig1' with 'figure' in the script, it does not work:

    Template:
    <umbraco:Macro figure="fig1" Alias="ShowFigure" runat="server"></umbraco:Macro>

    Script:
    <a href="@Library.MediaById(Model.figure).umbracoFile">
    <img src="/imagegen.ashx?width=550&[email protected](Model.figure).umbracoFile" alt="" />
    </a>

    The page shows the ImageGen 'Hello, world!' error, and the source shows no image:

    <img src="/imagegen.ashx?width=550&image=" alt="" />

    However, if I put <p>@Parameter.figure</p> in the script, it shows the parameter contents correctly, 'fig1' (w/o quotes), on the webpage, so I know it's getting there.

    I think I've tried all the possible combinations of "" and [], plus tossing in an occasional '#' for good measure, in both the template/parameter and the script but haven't figured out the magic.

    Help!

Please Sign in or register to post replies

Write your reply to:

Draft