Expand my Community achievements bar.

Increment / decrement counter checks with sightly

Avatar

Level 4

Hi ,

   I'm trying to achieve dynamic navigation , where in author can specify depth level and navigation automatically builds up to that depth level .I'm trying to achieve this use case using sightly . 

  I have achieved the dynamic navigation using data-sly-template and works fine , something like below ,

 <nav class="Secondary-navigation" role = "navigation">
         <ul data-sly-list.page="${topnav.rootPage.listChildren}" data-sly-unwrap>
           <div data-sly-call="${descendants.nav  @ page=page ,depth= [[[[]]]] }" data-sly-unwrap></div>
        </ul>
 </nav>

I have referrd tower of hanoii  https://twitter.com/sightlyio/status/545586838342488064 to set a counter for depth . 

 

Now instead of harcoding  depth as  empty iterables  [[[[]]]] , i 'm trying to dynamically generate  . I'm struggling to achieve it  . 

Using java class extended form wcmuse , i'm returning string as [[[[]]]] , but sightly doesn't seem to pick if I pass as strings . Do i need to pass any empty iterables ?  Can any one throw any pointers for this ? Much appreciated . 

2 Replies

Avatar

Employee

Are you able to send some code that doens't work with the use-api?

I don't fully understand this.

Avatar

Level 4

Hi Feike,

 

The above pasted code works absolutely fine for me. In the above code if you notice there are sets of empty iterates barcoded (  [[[[]]]]  ) . So as explained in blog of achieving " tower of Hanoi" using sightly, this empty iterables can be used as counters .

 

What I'm trying to achieve is to generate these empty iterables dynamically ,

so like for number 4 , it should return [[[[]]]], for 3 [[[]]] and so on... I'm trying to return empty string in the format as [[[[]]]] from Java code but sightly seems to ignore if I return strings. Not sure how I can return as empty iterables in the same format ?

Thanks in advance