Copied to clipboard

Flag this post as spam?

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


  • William Burnett 213 posts 262 karma points
    Feb 02, 2013 @ 15:22
    William Burnett
    0

    Get Sort Order of Media Items

    We can now drag and drop media items in the media preview area and sort them as we see fit. However, I don't see an obvious way to use the sort order in a gallery or page.


    Example:

    I have 100 media items in a folder that I want to display in a gallery.

    I have added a checkbox field "showInGallery" to the Memdia Type.

    I understand how to build an XSLT to show only the images with a check in showInGallery field, but I don't want them ordered by the nodeID or sortOrder corrosponding to the TREE. I would like to be able to use the "sort order" derived from the drap and drop order on the media preview page.

     

    WHERE is the information stored and how do I access it. It is clearly NOT stored in the ContentXML table or anywhere else I can find it.

  • William Burnett 213 posts 262 karma points
    Feb 04, 2013 @ 15:56
    William Burnett
    0

    A LITTLE HELP HERE FOLKS... Please...

     

    Is this the same issue from 2 years ago?

    http://our.umbraco.org/forum/core/41-feedback/12159-Refresh-media-cache-after-sorting

     

    Anybody?

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 06, 2013 @ 04:20
    Shannon Deminick
    0

    I've just logged this issue... I have a feeling this is most likely the cause:

    http://issues.umbraco.org/issue/U4-1653

     

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 06, 2013 @ 04:21
    Shannon Deminick
    0

    In order to do a sort like it's done in the back office you'd have to use the data api's (not cached versions). This could be a bit database intensive for front-end rendering.

  • William Burnett 213 posts 262 karma points
    Feb 06, 2013 @ 14:34
    William Burnett
    0

    I don't get it...

     

    Why is there not a "SortOrder" made available for XSLT or other code. Is it unreasonable to think that somebody would want to SORT media items for display, just as they SORT other node and data types?

     

    So media types (Images in this case) need to have a DisplayOrder property. That property should be updated for each item in the folder when media items are ordered in the bag end by drag and drop. Clearly the "default" order would be the SortOrder property used to populate the node tree.

    In that way, say we have a folder with 100 images. A photo gallery page could LOOP through all 100 images to populate the thumbnails on the gallery page, instead of the developer having to drop them in during site creation. Are we saying that this is too code/DB intensive? (Honest questions, as I don't know).

     

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 06, 2013 @ 14:57
    Shannon Deminick
    0

    Cached media does expose a sort order, it's in the XML that is resolved when you use library.GetMedia (assuming that is how you've attempted to do this and it's not working?) You asked how it's done in the back office and I've mentioned that its using the data api's not front-end apis but I didn't say that you can't sort on the front-end... i think that's what this discussion is all about... and there's probably some isuse there that it is not working properly for everyone. I'm trying to look in to this now so you'll have to give me some time to figure out what is going on, if there's a bug and how to do it properly on the front end. stay tuned.

  • William Burnett 213 posts 262 karma points
    Feb 06, 2013 @ 15:26
    William Burnett
    0

    I have not attempted to write any code yet, as I was not clear on what property to sort by. When I went looking, I got more confused :)

    The end goal was to be able to build a gallery template with a content picker that takes a media folder as the parameter. I added a property to the IMAGE media type called "ShowInGallery" so that my XSLT could loop through the folder and only populate the gallery page (on the front end) with the selected images. The problem is that I need to control the order in which the images are displayed and that is where I stumbled.

    I was just looking for a way to build gallery pages by sorting using drag and drop in the back end and not having to resort to picking or inserting each image into the content editor.. Using the traditional method, If (when) changes need to be made gallery, the entire page content must be edited or shuffled. The "new" method I am trying to implement would simply mean sorting the items in the backend and checking, or uncheching the ShowInGallery checkbox for each item. Makes sense, or am I attempting to do something that is not going to be possible?

     

    Thanks,

    Bill 

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 06, 2013 @ 20:40
    Shannon Deminick
    0

    @William we currently already have drag/drop support in the back office for sorting, you just click on the folder node (in media section) and the UI displays on the right and you can move stuff around.

    This is a big bug though: http://issues.umbraco.org/issue/U4-1653 and this will be preventing this all from working properly. We'll be releasing a patch release very very soon for it.

    Once fixed the library.GetMedia call for xslt will ensure that the media cache is always up to date and the sort order in the xml returned is correct. 

    This should all be currently possible but you'd have to bump the web.config to clear the cache each time you build a gallery and sort nodes... not ideal. Of course once this patch is out then should all be fine. 

    Does this answer your question/concern?

  • William Burnett 213 posts 262 karma points
    Feb 06, 2013 @ 21:40
    William Burnett
    0

    Shannon,

    I was aware that there is drag and drop sort capability in the back office but as mentioned, was not aware that sorting in the back office exposed that sort order at page load time to macros, etc.

     

    I think that answers my question. I will try and build my gallery page and see what I come up with.

    Thanks 

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 06, 2013 @ 21:44
    Shannon Deminick
    0

    Here's a quick Xslt example:

    <xsl:template match="/">
        <ul>
            <xsl:for-each select="umbraco.library:GetMedia(1050, 1)/Image">
                <xsl:sort select="@sortOrder"/>
                <li>
                    <xsl:value-of select="@nodeName"/> - <xsl:value-of select="@sortOrder"/>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>

    This will list out all child Image items of media item (1050.. which could be a folder) and it is order by the 'sortOrder'. Each list item renders out the node name and it's current sortOrder value.

    I haven't written a demo yet in MVC/Razor but is probably nicer (... since i'm not a fan of xslt :P ), however I think there's another issue with Examine and sorting media and in MVC/Razor it uses the Examine cache to get some media data which is much faster. I have to look in to that bug soon too and see if it still exists.

     

  • William Burnett 213 posts 262 karma points
    Feb 10, 2013 @ 15:42
    William Burnett
    0

    I can not get the GetMedia call to work. I have tried using the code above and numerous other itterations from the forum, regardless of the NodeID I use (explicity taken from the media section, or passed in by a media picker and macro.

     

    I can print the  value-of select and return the chosen ID, so that that works, but a value-of from within the for-each loop never prints (again regardless of the method I use.

     

    Thoughts?

  • William Burnett 213 posts 262 karma points
    Jul 12, 2013 @ 19:17
    William Burnett
    0

    So... we are 6.whatever and the back office drag and drop media sort STILL DOES NOT WORK.

     

    Really folks... this is getting old. Even better, the "issue" link posted above does not work becuase we no longer use the issue tracker. Why do we abandonden so much needed content every 2 or so years. Is it too much to ask that the old content be linked or available somehow. I spend more time farting around with the stupid project that it is worth, 90% of that time is spent tracking down documentation for upgrades, bugs and undocumented stuff that should be documented. 

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jul 15, 2013 @ 05:02
    Shannon Deminick
    0

    Not sure what link you are referring to but the link listed previous to this post is this one: http://issues.umbraco.org/issue/U4-1653 which works just fine. I've also just tested this in 6.0.7 and sorting of media items also works just fine. I've created a screencast demonstrating this: http://screencast.com/t/KTzRD8tUuT

     

  • William Burnett 213 posts 262 karma points
    Jul 15, 2013 @ 15:57
    William Burnett
    0

    Shannon,

     

    The link is working now, for some reason it was not when I tried the other day.

     

    Thank you for taking the time to post the screencast. I think my comments and frustration have confused my current issue. I have been able to get the sorting to work in the same fashion you showed in the screencast. However, it was my understanding that we would be able to SORT the media items in the right hand panel by dragging their icons around instead of having to sort in the columnar list. Was I mistaken, or is this still a "broken" feature?

     

     

  • Funka! 398 posts 661 karma points
    Jul 16, 2013 @ 01:33
    Funka!
    0

    There was also issue U4-1027 which I know had a workaround for the 4.x branch, but in latest 6.1.2 this seems to work correctly out of the box for me now? I would recommend if not working for you, see if you can check the Firebug console or the Chrome Inspector to look for any obvious errors?

  • William Burnett 213 posts 262 karma points
    Jul 24, 2013 @ 05:42
    William Burnett
    0

    I am not so sure why this is so hard to communicate:

    I have upgraded to 6.1.2

    In the backend media section there are TWO areas. The lefthand area where the TREE is and the righthand areas where the PREVIEW is.

     

    What works:

    Media sorting works in the TREE when you right click and choose SORT. If the tree or node is refreshed the sorted items retain their position. GetMedia reflects (for the most part) the new sort order.


    What DOES NOT WORK:

    Dragging to arrange media items in the TREE directly without choosing "sort" from the right click menu

    Dragging to arrange media items in the PREVIEW area.

    You can drag and drop in either area until your heart is content, but when you refresh the node, the sort order is not saved.


    So my statement: It was my understanding that dragging directly in the tree and/or in the preview area was to be a feature!

    My question: If the above is true, why is this still broken over a year later and why is it getting no attention?

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jul 24, 2013 @ 06:31
    Shannon Deminick
    3

    Drag/drop in the tree has never been a feature of Umbraco, it's not on the road-map (currently) but there is a pending pull request to support this but it requires further review feedback and updates to make sure it works properly and doesn't cause more problems than good.

    Drag/drop in the RIGHT hand side does indeed work, I've tested a fresh install of 6.1.2 and in the 6.1.3 branch with the same result.

    http://screencast.com/t/qq57uCiY

    So, if it is not working for you then we need to figure out why. Captial letters aren't going to help anyone so lets start making gains and figure out how to replicate the issue. Are you getting javascript errors when performing this action? 

  • William Burnett 213 posts 262 karma points
    Jul 24, 2013 @ 16:42
    William Burnett
    0

    Thank you for the clarification with regard to the tree functionality.

    As for my use of CAPITALS... They were use to ensure clarity, as there has been some confusion with regard to what I have been trying to articulate (likely my fault).

     

    6.1.0 upgraded from 6.0 no JS errors in IE10 or Chrome

    Functionality not working in either browser. I can drag the thumbnails around, but the order is not saved when the nodes are reloaded.

     

     

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jul 24, 2013 @ 16:50
    Sebastiaan Janssen
    0

    @William Try deleting ~/App_Data/Temp/ClientDependency/*.* and then increasing the version in ClientDependency.config by 1 and see if that helps.

    If it doesn't, you could check in Fiddler what the results is of the call to /umbraco/webservices/nodeSorter.asmx/UpdateSortOrder is. The response body should be empty.

    If you have a lot of media items then sorting then my comment on the issue might help: http://issues.umbraco.org/issue/U4-1027#comment=67-3093

  • William Burnett 213 posts 262 karma points
    Jul 24, 2013 @ 17:55
    William Burnett
    0

    I have just upgraded another site to 6.1.2

     ~/App_Data/Temp/ClientDependency/*.*

    Increased ClientDependency.config by 1

    Restarted Services (Azure)

    Tested in Both IE10 and Chrome

    Still not working.

    It may be important to note that my "media" items have some custom fields.

    ToolTipText (Text)
    ShowInGallery (Ucomponents Toggle)
    GalleryText(Tex)

    All (3) on the "image" tab. Their purpose is self explanatory. Could this be the issue?

     FWIW: issues.umbraco.org appears to be down for the last hour or so

     

    No idea how to use fiddler but I tried: I am seeing the NodeSorter.asmx/UpdateSortOrder returning what appears to be an error in the result list (500)

     

    Server Error in '/' Application.


    Request format is unrecognized for URL unexpectedly ending in '/UpdateSortOrder'.

      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/UpdateSortOrder'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/UpdateSortOrder'.]
       System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +489333
       System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
       System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
       System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
    


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033 
  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Jul 24, 2013 @ 18:45
    Sebastiaan Janssen
    0

    Sorry for the issuetracker outage, an upgrade of the software took longer than expected.

    Good to see we have a real error now, this solution should work for you: http://issues.umbraco.org/issue/U4-1027#comment=67-3093

    We'll update this code (probably for 6.1.4 to use Web API calls instead of webservices, that will prevent other people from running into the same issue). 

Please Sign in or register to post replies

Write your reply to:

Draft