Copied to clipboard

Flag this post as spam?

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


  • Gionata Aladino Canova 21 posts 42 karma points
    May 05, 2012 @ 00:36
    Gionata Aladino Canova
    0

    4.7.2 break standard razor macros

    Hi

    The standard Umbraco Media Macro stop working with Umbraco 4.7.2.

    ...

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @if (Model.HasProperty("relatedMedia") && Model.RelatedMedia != 0) {
    <p>Simple: <br />
    <img src='@Model.Media("relatedMedia", "umbracoFile")' />
    </p>

    ...

    return "Error loading MacroEngine script (file: )"

    The problem is in the if statement. This script

    @if (Model.HasProperty("immagineTesto") )

    work. The test

    Model.immagineTesto!= 0

    return error.

  • Jan Skovgaard 11264 posts 23594 karma points MVP 9x admin c-trib
    May 05, 2012 @ 01:28
    Jan Skovgaard
    0

    Hi Gionata

    From the changelog for 4.7.2 it appears some changes in fetching media with Razor has been made. However I'm not sure what has been the issue earlier on and how it has been fixed.

    But what happens if you cast the property to a string? Like this (string)Model.RelatedMedia !=0

    /Jan

     

  • Gionata Aladino Canova 21 posts 42 karma points
    May 05, 2012 @ 01:51
    Gionata Aladino Canova
    0

    Hi Jan

    Same problem. I made several attempts.The type returned by GetType is System.String

    I'll note that the macro is available in the default combobox for Umbraco. If Umbraco's developers have changed something, had to change the macro too.

    Gionata

  • Jan Skovgaard 11264 posts 23594 karma points MVP 9x admin c-trib
    May 05, 2012 @ 02:39
    Jan Skovgaard
    0

    Hi Gionata

    Hmmm yes then it looks like it it's a bug, which should be reported at codeplex - If you report it as a bug at some point please post a link to the issue in here so others who come accross this issue can vote it up.

    I'll of course let you know if I figure something out on how to solve the issue.

    /Jan

  • Gionata Aladino Canova 21 posts 42 karma points
    May 09, 2012 @ 22:18
    Gionata Aladino Canova
    0

    Another strange similar problem. Before 4.7.2 this code line run:

    @Model.prodottoPrezzo.ToString("c")

    The type of fields is Currency. With 4.7.2, if the field value is a number with decimal (ex. 12.45), all run. If the field value is a number without decimal (ex. 12), the macro render "Error loading MacroEngine script"

    Gionata

  • Gionata Aladino Canova 21 posts 42 karma points
    May 09, 2012 @ 22:26
    Gionata Aladino Canova
    0

    Created http://umbraco.codeplex.com/workitem/30810.

    Also created http://umbraco.codeplex.com/workitem/30811, for the following problem

    The code line
    foreach (Media pic in gallery.GetDescendants())
    seem not working with 4.7.2!

  • Heather 20 posts 41 karma points
    Oct 06, 2012 @ 16:38
    Heather
    0

    I know this reply is a few months late.... but I changed the script slightly and it works for me in 4.9.0

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @if (Model.HasProperty("pageMast") && Model.Media("pageMast") != null) {
        <p>Simple: <br />
            <img src='@Model.Media("pageMast", "umbracoFile")' />
        </p>

        <p>Advanced: <br />
            @{
                var image = @Model.Media("pageMast");
            }
            <img src='@image.UmbracoFile' alt='@image.Name' />
        </p>
    } else {
        <p>
            This page doesn't contain a MediaPicker property with the alias of 'RelatedMedia'
            or No image is selected on this page
        </p>
    }

Please Sign in or register to post replies

Write your reply to:

Draft