Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Macro Nested Children get paren View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/9/2013 8:01:45 AM
   
Macro Nested Children get paren
I need to get a childs parent node even if is nested 3, 4 or 5 levels deep. For instance:

root
- level 1
-- level 2
--- level 3
---- level 4
----- level 5

On level 2 I have a hierarchical viewer with transformations displaying all pages on level 3 and when a level 3 item is selected level 4 items are displayed in a nested <ul>. I only display 2 nested levels in the navigation but there could be as many as 5 levels below the level 2 page (where the hierarchical viewer is). When the user selects either level 3 or level 4, the css class is set to "current", which works as expected. When they select an item on level 5 how can I set the css class of levels 3 or 4 to "current" knowing that level 5 is still in the node of level 2, 3 or 4?

Right now I can use this
Convert.ToInt32(Convert.ToString(Eval("NodeID"))) == CMSContext.CurrentDocument.NodeParentID
to check 1 level above but this is limiting.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/10/2013 1:47:51 AM
   
RE:Macro Nested Children get paren
Hi,

Have you tried using the K# syntax and create a loop, e.g. a WHILE cycle in which you will check the level of given node?

In the first cycle you will get the NodeParentID - using this ID you will check the NodeLevel. It may be little bit complex loop but it will work.

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/16/2013 12:46:55 PM
   
RE:Macro Nested Children get paren
I'm guessing I should create a custom macro for this. But I wonder if there isn't a method already for it because what I want to happen is already working on the CSS List Menu webpart. If I set it to only select 2 levels deep and there are 6 levels, if I check the option to "Highlight all items in path" it does so. Any thoughts on what that method is or how I could utilize that same functionality?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 7/18/2013 1:18:25 AM
   
RE:Macro Nested Children get paren
Hi,

The list menu is using the API. Your custom macro would use the same. But you can achieve it by creating a loop/cycle in the K# macro in the same way as in the custom macro code and then you will use properties the same as in the API. As I mentioned above. The NodeParentID and NodeLevel to check if you are on the levet you want to be.

Best regards,
Juraj Ondrus