Copied to clipboard

Flag this post as spam?

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


  • Niklas Hjelm 104 posts 125 karma points
    Apr 20, 2012 @ 17:54
    Niklas Hjelm
    0

    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\"" : ""; @node.Name @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

  • Douglas Ludlow 210 posts 366 karma points
    Apr 20, 2012 @ 19:23
    Douglas Ludlow
    0

    Could you try reposting your code. This is all I got:

    @using umbraco.MacroEngines
    @inherits 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);
    }
    }
    }
  • Niklas Hjelm 104 posts 125 karma points
    Apr 20, 2012 @ 19:55
    Niklas Hjelm
    0

    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>   

    }

Please Sign in or register to post replies

Write your reply to:

Draft