Copied to clipboard

Flag this post as spam?

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


  • Psib3r 70 posts 119 karma points
    Jan 25, 2013 @ 16:47
    Psib3r
    0

    HELP!

    I am struggling with some razor.

    I am trying to create a footer for the site I am working on that should be something like

    <div class="one_fourth text-align-left">
      <ul>
        <li>...</li> (6 list items)
      </ul>
    </div>
    
    repeated 4 times

    I am traversing the structure looking for a showInFooter flag, this is what I have, but the problem is keeping track of what number the item and column is up to

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{ 
    var startLvl = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.StartLevel);
      var finishLvl = String.IsNullOrEmpty(Parameter.Level) ? 5 : int.Parse(Parameter.FinishLevel);   
      var parentName = @Model.AncestorOrSelf(startLvl);
      
    if (parentName != null) {
    @:<div class="one_fourth text-align-left"><ul>
        @traverse(parentName,startLvl,finishLvl, 1, 1);
    @:</ul></div>
      }
    }
    @helper traverse(dynamic parent,int startLevel,int finishLevel, int i, int c)
    {
    foreach (var node in parent.Children) {
    if (node.HasProperty("showInFooter")){
        if (node.GetProperty("showInFooter").Value == "1" && c < 5) {
            @:<li><a href="@node.Url">@node.GetProperty("umbracoURLName").Value</a></li>
    if ((i % 6) == 0)
    {
    c++;
            @:</ul></div>
    @:<div class="one_fourth text-align-left"><ul> i = 0;
            }
    i++; } }
        @traverse(node, startLevel, finishLevel, i, c);
      }
    }

     

  • 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