I am trying to write some XSLT to select the top 10 nodes based on the number of child nodes, however I am struggling to get this to work. Does anyone have an similar examples I could look at?
For example if I have 100 categories and each category has 1 or more products, how do I get the top 10 categories (based on the num of products they contain).
In the example above, I get all the children where the document type is BlogPost, and the .Where("Visible") means that I only shows the blopost that not have the UmbracoNaviHide set to true.
Then I order the blogposts by their creating dates, so the newest is alway on the top. and the Take makes you possible to difine how many items you want to display. In your case you want to dispay 10, so therefor Take(10).
@item.Summary references to a property on the document type for a BlogPost, and then I also make a link to the page, and the link text is the name of the item in the content tree
I hope this can help you getting what you needed, and make sense.
What i want to make is sort the blog posts by comment count, then take the top 3 post as popular posts.
The logic could be something like creating and array then adding the posts & child count to the array. Then sorting array by child count. And lastly take desired amount of posts and do whatever you want.
I'm not an advanced razor coder. I'll try the above method in a free time.
Select top 10 ordered by child node count
I am trying to write some XSLT to select the top 10 nodes based on the number of child nodes, however I am struggling to get this to work. Does anyone have an similar examples I could look at?
For example if I have 100 categories and each category has 1 or more products, how do I get the top 10 categories (based on the num of products they contain).
Thanks
Hi,
The basic selection could be done by sorting with the count() function, e.g., if the subpages of currentPage are the categories:
/Chriztian
I want to order blog posts by children count by razor. Any ideas?
TIA
Hi TIA,
Maybe this could be an inspiration for you to find the right solution.
In the example above, I get all the children where the document type is BlogPost, and the .Where("Visible") means that I only shows the blopost that not have the UmbracoNaviHide set to true.
Then I order the blogposts by their creating dates, so the newest is alway on the top. and the Take makes you possible to difine how many items you want to display. In your case you want to dispay 10, so therefor Take(10).
@item.Summary references to a property on the document type for a BlogPost, and then I also make a link to the page, and the link text is the name of the item in the content tree
I hope this can help you getting what you needed, and make sense.
/Dennis
What i want to make is sort the blog posts by comment count, then take the top 3 post as popular posts.
The logic could be something like creating and array then adding the posts & child count to the array. Then sorting array by child count. And lastly take desired amount of posts and do whatever you want.
I'm not an advanced razor coder. I'll try the above method in a free time.
is working on a reply...