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)
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;
}
is working on a reply...