Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Floffy 26 posts 33 karma points
    Jul 11, 2009 @ 17:10
    Floffy
    0

    How to sort nodes from .net usercontrol?

    I have a usercontrol (.net) that creates pages. I would like to sort the pages when done. To make it even more difficult I would like to sort by name, but put a specific page as the first (like an index-page). How do I do that?
    I’m using the nodefactory in V4
    Second question: is it possible to reload the content tree, in the backendm from the usercontrol, after the sort is made? 

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Jul 12, 2009 @ 13:38
    Peter Gregory
    1

    Im not sure how you are doing this with the NodeFactory as it read only.  Dont you mean umbraco.cms.businesslogic.web?

    Anyhow to sort nodes throught the API look at the documents SortOrder property.  This is an interger value to set the sort position relative to its siblings SortOrder property.

    You would need to get the sibling document collection via the parents children property and then sort the array by the first name.  You will need to write your own sorting code but there is plenty of stuff out there on the web on sorting arrays.  After this you would then need to set the SortOrder property of each of those documents and save them back to the db. 

    The next time the tree is loaded in the admin it would have your new docs in the new order.

    I know I havent given any code but there should be enough for you to get started.  There are some gems on saving documents to the database no this wiki page. http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties

     

     

Please Sign in or register to post replies

Write your reply to:

Draft