Which works fine and gives me 5 pictures from the correct category. The problem with this is that the images are all the same regardless of which image in the category I'm on. Any clues on how to get the images to change as I navigate through the category?
Flickr like set navigation
Hi!
I'm looking for some help on how to create a flickr like set navigation. Today I'm using this
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var startLevel = String.IsNullOrEmpty(Parameter.Level) ? 2 : int.Parse(Parameter.StartLevel); var finishLevel = String.IsNullOrEmpty(Parameter.Level) ? 5 : int.Parse(Parameter.FinishLevel); var parent = @Model.AncestorOrSelf(startLevel); if (parent != null) { @traverse(parent,startLevel,finishLevel) ; } } @helper traverse(dynamic parent,int startLevel,int finishLevel) {
@foreach (var node in parent.Children.Where("Visible").OrderBy("sortorder").Take(6)) { var selected = Array.IndexOf(Model.Path.Split(','), node.Id.ToString()) >= 0 ? " class=\"selected\"" : ""; @if (selected != "" && @node.Level <= finishLevel) { @traverse(node, startLevel, finishLevel); } }
}
Which works fine and gives me 5 pictures from the correct category. The problem with this is that the images are all the same regardless of which image in the category I'm on. Any clues on how to get the images to change as I navigate through the category?
Thanks / Niklas
Could you try reposting your code. This is all I got:
Ok, new try
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
var startLevel = String.IsNullOrEmpty(Parameter.Level) ? 2 : int.Parse(Parameter.StartLevel);
var finishLevel = String.IsNullOrEmpty(Parameter.Level) ? 5 : int.Parse(Parameter.FinishLevel);
var parent = @Model.AncestorOrSelf(startLevel);
if (parent != null) { @traverse(parent,startLevel,finishLevel) ; }
}
@helper traverse(dynamic parent,int startLevel,int finishLevel)
{
<ul>
@foreach (var node in parent.Children.Where("Visible").OrderBy("sortorder").Take(6))
{
var selected = Array.IndexOf(Model.Path.Split(','), node.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
<[email protected](selected)>
<a href="@node.Url"><img src="@node.huvudBild.mediaItem.Image.umbracoFile?width=100&height=100&crop=auto" alt="@node.Name" /></a>
@if (selected != "" && @node.Level <= finishLevel)
{ @traverse(node, startLevel, finishLevel);
}
</li>
}
</ul>
}
is working on a reply...