Copied to clipboard

Flag this post as spam?

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


  • Chris Moss 5 posts 25 karma points
    Oct 30, 2012 @ 11:47
    Chris Moss
    0

    GetDynamicContentById not found in the Umbraco namespace

    Hi All,

    I am a developer (django and php (yuck) mainly with some actionscript Flex/Flash work) with a company based in Scotland and I am working on a project that is using this CMS. I am 100% new to it and to .NET in general (currently learning ASP.NET C#).

    I have an issue creating a navigation macro with razor, and I have seen a few examples that all seem to be based on the current page ($currentPage) when using XSLT (which I am not a fan of), and for a menu I can't see see how thats possible, but I digress.

    I am trying to create this marco to first create a sub menu with a very specific design (dont ask) and I need to parse a page id and then get the child pages of that specific parent. I am passing the parameter to the macro without issue, but when I attempt to the run a foraech loop using Umbraco.GetDynamicContentById() Visual Studio reports that this is not in the namespace and obviously the macro fails. The code is:

    @foreach(var child in Umbraco.GetDynamicContentById(source).Children) {
    if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) {
        <li><a href="@child.NiceUrl">@child.name</a></li>
    } }

    I am have not specified any @using to import and other namespases. Any pointers would be great as this project has a stupidly tight deadline. I cannot show you the menu directly as I am under a NDA. But it is a typical parent content page with some children.

    Thanks

  • Chris Moss 5 posts 25 karma points
    Oct 30, 2012 @ 11:54
    Chris Moss
    0

    For those who want it this is the entire macro.

    @{
    var source = string.IsNullOrEmpty(Parameter.Source) ? Model.CurrentPage.Id : Parameter.Source; <div class="subMenu"> <div>
    <ul>
    @foreach(var child in Umbraco.GetDynamicContentById(source).Children) {
    if (child.umbracoNaviHide != null && !bool.Parse(child.umbracoNaviHide)) {                 <li><a href="@child.NiceUrl">@child.name</a></li> } } </ul> </div> <div>
    </div>
    </div>
    }

    The empty div will be populated with something else so just ignore it it

  • Chris Moss 5 posts 25 karma points
    Oct 30, 2012 @ 11:56
    Chris Moss
    0

    The error on the frontend is ERROR LOADING MACROENGINE SCRIPT (FILE: ********.CSHTML)

  • Chris Moss 5 posts 25 karma points
    Oct 31, 2012 @ 15:21
    Chris Moss
    0

    This is for version 4.9.

    !BUMP!

  • Chris Moss 5 posts 25 karma points
    Nov 01, 2012 @ 15:40
    Chris Moss
    0

    Ok for those who may come up against a similar problem of dealing with a sub navigation issue I managed to cobble together this thatsnks for the feedback.

Please Sign in or register to post replies

Write your reply to:

Draft