Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Jun 22, 2015 @ 10:11
    Ayo Adesina
    0

    Via Code - Change the order of Umbraco Nodes in Back office

    During the Gathering Node data event, I want to run some code and based on the result I want to change the order of nodes in the Umbraco back office.

    Is this possible?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 22, 2015 @ 11:05
    Ismail Mayat
    2

    Ayo,

    The contentservice api has sort see https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService

    .Sort(IEnumerable items, [int userId = 0], [bool raiseEvents = true]) Sorts a collection Content objects by updating the SortOrder according to the ordering of items in the passed in System.Collections.Generic.IEnumerable. Returns True if sorting succeeded, otherwise False. Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.

  • Ayo Adesina 445 posts 1059 karma points
    Jun 22, 2015 @ 15:45
    Ayo Adesina
    0

    Thanks Ismail exactly what I was looking for.

    I'm not sure if you remember my question about sorting tags by most used?

    In the end this is how I solved it - by keeping the order in umbraco correct, so every time an article is added or updated, I'm searching the index, working out which tags are most used and then changing the order of the nodes in umbraco.

    So on the front end I just loop through the nodes in the order that they are stored in umbraco, no need to do any looping logic to work out what is used. - Fast for the end user.

    Even in the back office, because I am just searching a custom index to see how many results I have for each tag, this is lighting quick to and is not noticeable.

    Really enjoyed cracking that one :-)

    Thanks for all your answers, really saved me time.

    Ayo

Please Sign in or register to post replies

Write your reply to:

Draft