Copied to clipboard

Flag this post as spam?

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


  • bob baty-barr 1180 posts 1294 karma points MVP
    Aug 03, 2012 @ 15:49
    bob baty-barr
    0

    Error loading MacroEngine script

    Getting several load errors on a clean install on v4.7.2 - any thoughts?

  • bob baty-barr 1180 posts 1294 karma points MVP
    Aug 03, 2012 @ 15:53
    bob baty-barr
    0

    and that would explain it! thanks Jorge! i will install 4.8 and give it a whirl!

  • fabrice 104 posts 227 karma points
    Aug 15, 2012 @ 09:58
    fabrice
    1

    Hello Jorge,

    Thanks for the "fast" razor view (and the miniprofiler !! it's great)

    Just for info, here is the way I would write the Navigation.cshtm. I use DynamicNode (not dynamic ;) and GetChildrenAsList.Items.Where(xxx)

    In this case I don't have to get all children as an Array and do a filter afterwards.

    Of course I use GetChildrenAsList if I only need the first level children, otherwise I use GetDescendant

    PS : I didn't notice any performance improvement with my code throught...

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
        DynamicNode root = Model.AncestorOrSelf("Homepage");
       
       
        <ul class="nav">
        @{ var homeSelected = @Model.Level == 1 ? " class=\"active\"" : string.Empty; }
            <[email protected](homeSelected)><a href="@root.Url">@root.Name</a></li>

        @foreach (DynamicNode item in root.GetChildrenAsList.Items.Where(x => x.GetPropertyValue("UmbracoNaviHide") != "1"))
        {
            var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"active\"" : string.Empty;
           
            List<DynamicNode> listChildren = item.GetChildrenAsList.Items.Where(x => x.NodeTypeAlias == "Textpage").ToList();

            if (listChildren.Count() > 0)
            {
                <li class="dropdown">
                <a href="@item.Url" class="dropdown-toggle" data-toggle="dropdown">@item.Name</a>
                <ul class="dropdown-menu">
                @foreach (DynamicNode subItem in listChildren)
                {
                    <li><a href="@subItem.Url">@subItem.Name</a></li>
                }
                </ul>
                </li>
            }
            else
            {
                <[email protected](selected)><a href="@item.Url">@item.Name</a></li>
            }
        }
        </ul>
    }

     

Please Sign in or register to post replies

Write your reply to:

Draft