While writing a Sitecore query and running it against the XPath builder is completely feasible, there is a quicker way if you're just trying to get a child count.
Open up the Sitecore Content Editor, activate the node you want to get the number of children under and expand it.
Open up your Google Chrome Dev Console and run the following line of Javascript:
document.getElementsByClassName('scContentTreeNodeActive')[0].nextSibling.childNodes.length
This one-liner finds the active Content Tree node and discovers the number of child items living under it.
Note: This doesn't account for all descendants and only seems to work with Google Chrome, however, I've found this useful in a few situations now across any Sitecore version.
Enjoy!
0 comments:
Post a Comment