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 24, 2013 @ 14:51
    Psib3r
    0

    Help with helper or something better

    I have the following, which obviously does not work but is an example of what I want to do, I am basically trying to create up to 4 columns (div with list inside) of up to 6 items in each list, but I can't seem to close off the last list if there is less than 6 items in it, is there another way of getting the last value from the helper function?

    @{ 

     

    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) {

          var x = @traverse(parentName,startLvl,finishLvl, 1, 1);

    if(x > 1 && x < 6)

    {

    @:</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)

          {

            if (i > 6)

            {

            i = 1;

            c++;

            @:</ul></div>

            }

            if (i == 1)

            {

            @:<div class="one_fourth text-align-left"><ul>

            }

            @:<li><a href="@node.Url">@node.GetProperty("umbracoURLName").Value</a></li>

            i++;

          }

        }

        @traverse(node, startLevel, finishLevel, i, c);

        }

    return i;

    }

     

Please Sign in or register to post replies

Write your reply to:

Draft