Copied to clipboard

Flag this post as spam?

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


  • karen 186 posts 461 karma points
    Apr 11, 2014 @ 18:59
    karen
    0

    macro scripts work in 4.x but not in 6.1.6

    I am creating a site and using some templates/setup from another site in my company.

    That umbraco site is using 4.x (not sure which one, I don't have access to thier site).  They sent me some templates they are using and I'm trying to see how thier stuff is working by creating my own umbraco instance with the templates.  I am using 6.1.6.

    They have this, and it works on thier site (on 4.x)

    <umbraco:Macro runat="server" language="cshtml">@using umbraco.MacroEngines;@{DynamicNode node = @Model.AncestorOrSelf(2);@node.GetPropertyValue("cssFile")}</umbraco:Macro>

    but for me (on 6.1.6) that is throwing errors.  I had to change it to this to get it to work

    <umbraco:Macro runat="server" language="cshtml">@{@Model.AncestorOrSelf(2).cssFile}</umbraco:Macro>

    The error I get is basically :  error CS1002: ; expected  and looks like the GetPropertyValue is what is causing it (just a guess on that)

    Any ideas why that is?


  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Apr 11, 2014 @ 19:42
    Jeavon Leopold
    100

    Hi Karen,

    Your issue is that Umbraco v6 comes with Razor v2 while Umbraco v4 has Razor v1, the main difference is that Razor v2 will not allow the use of @ within a code block.

    So while you had this in v4

    @using umbraco.MacroEngines;
    @{
        DynamicNode node = @Model.AncestorOrSelf(2);
        @node.GetPropertyValue("cssFile")
    }
    

    You need to change it to this for v6

    @using umbraco.MacroEngines;
    @{
        DynamicNode node = Model.AncestorOrSelf(2);
        @node.GetPropertyValue("cssFile")
    }
    

    Jeavon

  • karen 186 posts 461 karma points
    Apr 11, 2014 @ 23:50
    karen
    0

    Thank you Jeavon!

Please Sign in or register to post replies

Write your reply to:

Draft