Copied to clipboard

Flag this post as spam?

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


  • Evan Jardine 108 posts 168 karma points
    Jul 08, 2011 @ 03:51
    Evan Jardine
    1

    Broken razor script testing 4.7.1 nightly builds

    Hi

    I've been doing some testing of the 4.7.1 nighltys and found a few of my razor scripts no longer work.  I'll start with a pretty simple one.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines
    @{
        DynamicNode source = new DynamicNode(@Model.activeMeetingYear);
        DynamicNodeList months = source.DescendantsOrSelf("MeetingMonth");
    }
    <div id="meetingSubNav">
        <ul>
            @foreach (DynamicNode month in months.Items.OrderBy(m => m.Name))
            {
                var liStyle = month.Name == "01" ? "class=first" : "";
                <li @liStyle><a href="#@month.Name">@month.GetProperty("MonthName")</a></li>
            }
        </ul>
    </div>

    This works fine in 4.7.0 but in the nightly instead of the property 'MonthName' it outputs umbraco.MacroEngines.PropertyResult.

    Can someone let me know what has change to cause this?

    Cheers

    Evan

  • Gareth Evans 143 posts 335 karma points c-trib
    Jul 08, 2011 @ 04:22
    Gareth Evans
    2

    Hi Evan

    GetProperty returns PropertyResult which is IProperty, it's part of the compatibility with being able to access media and nodes in the same way.
    This is because Media comes from Examine now, which doesn't have a GetProperty function and I was trying to standardise the access.

    You should change your script to use GetPropertyValue which will return the value, previously GetProperty would have fallen back to INode.GetProperty.

    I will implement IHtmlString on PropertyResult to return the property value which will allow GetProperty to either be used to get the property or output the property value as you are doing here.

    Gareth

Please Sign in or register to post replies

Write your reply to:

Draft