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:37
    Matthew
    0

    another passing parameters question - 3rd try

    Well, I hope persistance pays off, I seem to be unable to edit or delete the previous attempts:

    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&image=@Library.MediaById(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&image=@Library.MediaById(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!

     

  • Matthew 93 posts 153 karma points
    Jun 13, 2012 @ 01:55
    Matthew
    0

    Amazing how posting the question helps find the answer.  Had to chage the script to use GetPropertyValue:

    @Library.MediaById(Model.GetPropertyValue(Parameter.figure)).umbracoFile" 

    Thanks folks.  My apologies again for the redundancy.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies