Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > CMSListMenu and Classes View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 10/9/2013 1:21:22 PM
   
RE:CMSListMenu and Classes
In the Hierarchical viewer webpart. Set the WhereClause there. This way it will not ever get any documents that aren't suppose to be in the navigation so there will be no need to check for it in your transformation. You will know that if there are any child nodes they should be included.

User avatar
Member
Member
wynveen-dcim - 10/9/2013 1:25:56 PM
   
RE:CMSListMenu and Classes
I already have that in the where condition for the web part. That was part of the instructions in the link above. The issue is that in the item template at the top level, I need to add a class to the link if it has children, similar to this:
<a href="{% Transformation.GetDocumentUrl() %}</a>

The problem is that NodeChildNodesCount doesn't take into account whether it should be shown in the nav or not.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 10/9/2013 1:33:46 PM
   
RE:CMSListMenu and Classes
Ahh yes, you are correct. You may need to create a custom method to do the checking for you. It could get pretty messy if you attempted to do that in the transformation. In your transformation you can use
<script runat="server">
protected int GetVisibleChildrenCount(string docGuid)
{
// do some checking here in C# based on the current document to see if there are any children and if they should be shown in navigation or not
}
</script>
and call that within your transformation code

User avatar
Member
Member
wynveen-dcim - 10/9/2013 1:49:21 PM
   
RE:CMSListMenu and Classes
The more I think about this, the more it sounds like it's going to become a performance issue. So I decided to add a boolean field to the Page document type called MenuItemIsDropdown which I use instead of checking the count of children. I am thinking that my dropdowns may contain custom rich content in the future anyways (for which I'll add another field called MenuItemDropdownContent or something), so this will probably work best anyways. Thanks for the help.

User avatar
Certified Developer v7
Certified  Developer v7
lou - 9/9/2013 12:20:15 PM
   
RE:CMSListMenu and Classes
Hi Jan

I have used your code to successfully display 2 levels of documents however I would like to display the 2 levels within a dropdown list, is it possible to use the hierarchical viewer in this way?

Also is there an option/work around within the hierachical viewer similar to the 'display selected path only' property in the csslistmenu?

Regards
Lou

User avatar
Kentico Support
Kentico Support
kentico_janh - 9/10/2013 1:15:50 AM
   
RE:CMSListMenu and Classes
Hello,

1) With the hierarchical transformation you just specify what HTML code in what structure you want to render. Any menu functionality like dropdown or some visual effect like hiding fading and so on, you need to apply a css style or javascript on. Below is an example how to make a dropdown megamenu using hierarchical transformations:

Creating a Mega Menu using Hierarchical transformations

2) Yes, this should be possible to achieve just by an if statement in your item transformation where you check the current path. A similar approach is described in last part of the article below:

How to build up a menu using the hierarchical transformation

Best regards,
Jan Hermann

1 2 3