Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Determine if another document has child nodes View modes: 
User avatar
Member
Member
Jerreck - 12/12/2013 12:03:53 PM
   
Determine if another document has child nodes
How would I used NodeChildNodesCount to count the nodes of another document?

I need to change the visibility of a web part based on whether or not another document has children.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/13/2013 5:30:19 AM
   
RE:Determine if another document has child nodes
Hello Jerreck,

You can access all the documents via the Documents collection.
Example for the document "News":
Documents.WHERE("DocumentName='News'")[0].NodeChildNodesCount

Best regards,
Martin Danko

User avatar
Member
Member
Jerreck - 12/13/2013 10:32:29 AM
   
RE:Determine if another document has child nodes
Awesome, thank you :)

So if I also wanted to access the NodeID from the CMS_Tree table for a given DocumentID from the CMS_Document table, could I just use:

Documents.WHERE("NodeID=00000")[0].NodeChildNodesCount


Also, what is the 0 in the square brackets for? Is it expecting an argument?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/16/2013 5:55:23 AM
   
RE:Determine if another document has child nodes
Hello,

The zero is just index number - it indicates the first position in given collection.

Best regards,
Juraj Ondrus