Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    May 27, 2014 @ 13:13
    Sören Deger
    0

    Razor error after upgrade to 6.2.0

    Hi,

    after upgrade from 6.1.6 to 6.2.0 any Scripting Files show an "Error loading Macro Engine script" message.

    This is one of my simple scripts which are crashed:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
        foreach(var item in Model.AncestorOrSelf(1).Descendants("Aktion").Where("Visible").Take(1))
        {
            <div class="two_third last aktionsbox">
                <div style="padding: 10px 15px;">
                    <h2>@item.actionFieldTitle</h2>
                    <p>@Html.Raw(umbraco.library.ReplaceLineBreaks(item.actionField))</p>
                </div>
            </div>
        }
    }

    It seems that would be the error here in foreach:
    .Descendants("Aktion")

    It works great in 6.1.6 before.

     

    Has everything changed in Razor in 6.2.0? Any ideas?


    Best regards

    Sören

  • Sören Deger 733 posts 2844 karma points c-trib
    May 27, 2014 @ 13:31
    Sören Deger
    0

    It works with this code:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    foreach(var aktionen in Model.AncestorOrSelf(1).Children.Where("NodeTypeAlias==\"Aktionen\"")) { foreach(var item in aktionen.Children.Where("Visible").Take(1)) { <div class="two_third last aktionsbox"> <div style="padding: 10px 15px;"> <h2>@item.actionFieldTitle</h2> <p>@Html.Raw(umbraco.library.ReplaceLineBreaks(item.actionField))</p> </div> </div> } }

    Someone understands why this no longer works with the first code in 6.2.0?

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    May 27, 2014 @ 15:10
    Sebastiaan Janssen
    0

    Hmm, your first notation works just fine for me, so just as a test I installed a fresh 6.2.0 with the Simple starter kit and put this in a Scripting file (macroScripts\test.cshtml):

    @foreach(var item in Model.AncestorOrSelf(1).Descendants("umbTextpage").Where("Visible").Take(1)) {
        <h2>@item.Name</h2> 
    }
    

    And that works as a macro on the template (either masterpages or a view template) and also when inserted as a macro in the rich text editor and even as an inline macro in a masterpage:

    <umbraco:Macro runat="server" language="cshtml">
    
        @foreach(var item in Model.AncestorOrSelf(1).Descendants("umbTextpage").Where("Visible").Take(1)) {
            <h2>@item.Name</h2> 
        }
    </umbraco:Macro>
    

    So I'd advise to have a look in the log (App_Data\Logs\UmbracoTraceLog.txt) to see what's really going on.

  • Sören Deger 733 posts 2844 karma points c-trib
    May 27, 2014 @ 16:07
    Sören Deger
    0

    Hi Sebastiaan,

    something has gone wrong during the upgrade. In log I found lines with this:

    [7] WARN  umbraco.macro - [Thread 16] Error loading MacroEngine script (file: Aktionen.cshtml, Type: ''. Exception: System.Exception: ContentTypeService failed to find a content type with alias "WidgetTextBox". 

    In 6.1.6 I had a Document Type with name Widget-TextBox and alias Widget-TextBox. After upgrade the alias has automaticaly change to WidgetTextBox. It thus seems somehow to hang out together. Now, I have tested in a fresh 6.2.0  too and it works.

    Thank you!

     

    Sören

Please Sign in or register to post replies

Write your reply to:

Draft