Copied to clipboard

Flag this post as spam?

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


  • pieter van Uhm 23 posts 49 karma points
    Jul 21, 2014 @ 10:15
    pieter van Uhm
    0

    Add class to parent node

    Hi,

    I'm breaking my head on some little thing that i need to put in my code, i just need to add a class to the H3 and the DIV element, when the children of that element has a class Active - Or add a class to the parent of these children. for now i have the class Active to the LI active element added but i can't get it done for the above laying elements.

    Umbraco version: 4.9.0

    @using umbraco.MacroEngines;
    @{
        var count = 0;
        var startLevel = 2;
        var finishLevel = 3;
        var parent = @Model.AncestorOrSelf(startLevel);
        int children = 0;
    }
    
    @ulMenu(parent, startLevel, finishLevel)
    
    @helper ulMenu(dynamic parent, int startLevel, int finishLevel)
    {
        var children = @parent.Children.Count();
    
    
    @foreach (var node in parent.Children) { var Class = (@node.Id.Equals(@Model.Id)) ? "active" : String.Empty; var Aclass = @node.menuSubText.GetType() == typeof(DynamicNull) ? "navigation" : "navigation"; var itemName = Library.Truncate(@node.Name, 20, true); if (@node.Children.Count() > 0) { if (@node.hideInNavigation == false) { if (node.HasAccess) {

    @itemName @if (@node.Level.Equals(2) && !(@node.menuSubText.GetType() == typeof(DynamicNull))) { @node.GetProperty("menuSubText").Value }

    @if (@node.Level <= finishLevel && node.Name.ToLower() != "nieuws") { @ulMenu(node, startLevel, finishLevel) }
    } } } else { if (@node.hideInNavigation == false) { if (node.HasAccess) {
  • @itemName @if (@node.Level.Equals(2) && !(@node.menuSubText.GetType() == typeof(DynamicNull))) { @node.GetProperty("menuSubText").Value }
  • } } } }
    }

     

    Greetz Pieter

  • pieter van Uhm 23 posts 49 karma points
    Jul 22, 2014 @ 11:05
    pieter van Uhm
    0

    nobody :( ?

Please Sign in or register to post replies

Write your reply to:

Draft