Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Hierarchal menu issues View modes: 
User avatar
Member
Member
lwhittemore-emh - 11/15/2013 1:48:39 PM
   
Hierarchal menu issues
I am having an issue building a menu with the hierarchal viewer.

I am trying to build a basic unordered list menu with nested unordered lists.

<ul>
<li>test
<ul>
<li>Sub 1
<ul>
<li>Sub 2</li>
</ul>
</li>
</ul>
</li>
<li>test 2
<ul>
<li>Sub 1
<ul>
<li>Sub 2</li>
</ul>
</li>
</ul>
</li>
<li>test 3</li>
</ul>


How would I do this basic structure with the Hierarchal viewer. The problem I am running into is that I cannot get the nested ul in side the parent li and have them all close properly.

I have tried this Header transformation
<ul>


Footer transformation
</li></ul>


Item transformation
<%# IfCompare(Eval("NodeOrder"),1,"</li>","") %>
<li>some cde here to get links and what not


I have the if compare to check and see if it is the first item in it's section so that I do not get extra closing tags.

This would work fine, but the noderorder get's messed up and 1 is not always the value for the first item. In fact it seems to constantly get messed up whenever a new item is added.

I have also tried using the first item transformation without the closing tags to start and then having the rest use the closing with out the compare but it doesn't seem to get the first item in each level properly.

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/17/2013 2:52:35 AM
   
RE:Hierarchal menu issues
Hi,

Thank you for your message.

The Eval("NodeOrder") is actually returning the value out of the database table CMS_Tree which represents the Order of the node in the content tree and it doesnt have to be always 1. You could order the results by query but that wouldnt work if there would be some other documents before.

You can use the DataItemIndex and DataItemCount in your transformation->

<%# DataItemIndex %>
<%# DataItemCount %>

Which might help you. I would also refer you to the http://devnet.kentico.com/docs/devguide/index.html?hierarchical_transformations.htm and to our Sample corporate site where we have an example of hiearchical webpart under Examples -> Webparts -> Listing and viewers -> Documents

Kind regards,
Richard Sustek