Copied to clipboard

Flag this post as spam?

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


  • Madura Silva 27 posts 79 karma points
    Feb 02, 2015 @ 06:46
    Madura Silva
    0

    Delete Items from CurrentPage.AncestorsOrSelf()

    Hi

    I'm trying to create a Left navigation using Partial View Macro. To do that, I need to delete Home node form result of the CurrentPage.AncestorsOrSelf();

    Please let me know if anyone knows how to delete items from CurrentPage.AncestorsOrSelf()

    I have written that macro using Razor, now trying to convert to the Partial View Macro. But there is no much help for Partial View Macros

    Razor code

    umbraco.MacroEngines.DynamicNode currentNode = @Model;
    umbraco.MacroEngines.DynamicNodeList parentNodeList = currentNode.AncestorsOrSelf();
    parentNodeList.Items.RemoveAt(0);
    
  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 02, 2015 @ 12:12
    Jeroen Breuer
    100

    Hello,

    Here is some documentation for Partial View Macros: http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/

    The above code uses old Razor code and is not compatible with a Partial View Macro.

    Try something like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    var items = Model.Content.AncestorsOrSelf().ToList(); items.RemoveAt(0); 

    Jeroen

  • Madura Silva 27 posts 79 karma points
    Feb 02, 2015 @ 23:11
    Madura Silva
    0

    Thanks Jeroen, that worked for me ...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies