Asset list grouping - sort by asset tree position?


(Charlotte Westney) #1

Hi everyone,

 

hopefully this is a simple one!

I have an asset list, with Groupings set on folders.

How do I get the folders to appear in the list in the same order that they appear in the asset tree, rather than by asset name, asset id or any of the other sort by options? I'd like Edit+ authors to be able to create folders and move them around if necessary, so they can control the order of the folders and file assets that appear in the list.

 

I must be missing something simple, as I just can't figure it out!  

Thansk!
Charlie.


(Nic Hubbard) #2

If you are using grouping, I don't think there is a way to sort the groups by how they appear in the asset tree. :(


(Gaz J) #3

Hi Charlie

 

I think the only way to do this is if you have each folder as a defined root node and "Direct Links Only" set to yes - so probably won't work in this situation if users are creating new folders?


(Nic Hubbard) #4

Actually, thinking about this more. You could use two Asset Listings. The first, set to list folders with direct links set to Yes, and sorting set to no sorting. Doing this will make the list sort by what is shown in the asset map.

 

Next, create a second asset listing and use list_current_asset_id to list the children of those folders. (Let me know if you have never used list_current_asset_id)

 

Doing it this way gives you a little more control over grouping and should do exactly what you are after.


(Bart Banda) #5

Actually, thinking about this more. You could use two Asset Listings. The first, set to list folders with direct links set to Yes, and sorting set to no sorting. Doing this will make the list sort by what is shown in the asset map.

 

Next, create a second asset listing and use list_current_asset_id to list the children of those folders. (Let me know if you have never used list_current_asset_id)

 

Doing it this way gives you a little more control over grouping and should do exactly what you are after.

Yep, the best way. We do this quite often. 


(Charlotte Westney) #6

Hi guys,

 

Thanks for the solution. (Does seem a little daft to have to create 2 asset lists, to basically re-create the functionality of asset groupings - maybe a feature request to add in an option of 'by asset tree' to asset list sorting options would be a good idea, as that's the one that Edit+ authors can control the easiest ??)

 

I understand the concept, but I'm a bit unsure how the two lists hang together. For the list that sorts the folders, how do I then get the second list to list out the folders' child files - use a paint layout on the folder that nests in the second list... and still not sure how list_current_asset_id works. Any pointers really welcome!

Thanks again, Charlie.


(Nic Hubbard) #7

I understand the concept, but I'm a bit unsure how the two lists hang together. For the list that sorts the folders, how do I then get the second list to list out the folders' child files - use a paint layout on the folder that nests in the second list... and still not sure how list_current_asset_id works. Any pointers really welcome!

 

Here is what you need to do. First, create two asset listings.

 

Asset Listing 1

  • Asset Type: Folder
  • Root Node: Your Root node
  • Direct Children: Yes
  • Sorting: No Sorting

 

Asset Listing 2:

  • Asset Type: Children of folder asset type
  • Root node: Node above all folders, can be Site
  • Dynamic Parameters: Replacement Root node for listing, SESSION Variable, set to list_current_asset_id

Next, in Asset Listing 1 go to the Type Format and create a Nested Asset div and nest Asset Listing 2 here.

 

 

This should produce the listing that you are wanting. Asset List 1 controls the folder sorting and listing, Asset Listing 2 controls the children of the folder sorting and listing.

 

Hope this helps.


(Douglas (@finnatic at @waikato)) #8

Thanks Nic - It's quite useful to have that guide handy when you are creating an asset listing with nested asset listing :-)

 

My nested listing isn't sorting by the asset tree position (e.g. newly created assets at the top of the list in the asset tree are listed last) - anything someone setting up a nesting listing like this might need to check or correct if that behaviour appears?


(Nic Hubbard) #9

Thanks Nic - It's quite useful to have that guide handy when you are creating an asset listing with nested asset listing :-)

 

My nested listing isn't sorting by the asset tree position (e.g. newly created assets at the top of the list in the asset tree are listed last) - anything someone setting up a nesting listing like this might need to check or correct if that behaviour appears?

 

Did you make sure to set Direct Links Only to YES and Sorting to No Sorting?


(Douglas (@finnatic at @waikato)) #10

Aha! Direct Links need to be YES on both the parent and nested listing.  Thanks again Nic.


(Andrew Harris) #11

I've done this sort of thing using an asset listing to list just the folders - giving you the control you want over sorting, but then setting the type format to something like %asset_contents_paint_1234%, where 1234 is a paint layout that includes the second level asset listing using a current asset replacement root node. I also use this method to get access to all sorts of clever paint layout stuff that a normal asset listing can't do.


(Warwick Smith) #12

I went too far down the path of assuming it would work, and found this thread when it didn’t.

So I made a dirty hack of group listing by Asset ID. Not optimal, but a quick hack if you’re in a hurry.

I’ll take on this advice above in the future!

W.


(Tom Stringer) #13

At the risk of poking a well-flogged horse… Is there a particular reason why it’s not possible to have native tree-position sorting for asset lists that dont use direct links only? I’m just curious, because it’s a fairly common thing that we need to do and the workarounds get pretty convoluted pretty quickly. Is it just too tricky to configure?


(John gill) #14

I think it’s because in the general case you don’t necessarily have all the required information to do the sorting. Link order is only unique and meaningful within a single parent asset, so in the example case

  • a
    • 1
    • 2
      • i
      • ii
      • iii
  • b
    • 3
    • 4
      • iv
      • v
      • vi

If you had an asset listing that selected all the roman numeral assets, it would load the information about which order i,ii,iii go in, and the information about the order for iv, v, vi, but it wouldn’t have the information about which order the two groups should go in because those assets haven’t been loaded by the listing engine. It would need to query more assets than it would otherwise require to get that info.

“Asset Map” sort order might get you what you want. I’ve used it before with success but I’m not certain of its limitations - it might not play nicely with asset grouping?


(Tom Stringer) #15

Thanks John

In this case, it’s just a standard asset list (not grouped), with a single (dynamically-provided) root node, but I want it to list each of the immediate child folders as well as the current root node.

  1. Root node (dynamic - I want to show this is the results)
    1.1 Child folder 1
    1.2 Child folder 2

If I set it to Direct links only the current root node gets dropped, but if Direct links only is set to no then I lose that asset map sort order and I get.

  1. Root node
    1.1 Child folder 2
    1.2 Childer folder 1

I’ve tried using the “Asset Map” sort order setting, but it doesn’t seem to have an effect.


(Bart Banda) #16

I think what you are after is disabling Direct links only, and then printing the root node via the page contents bodycopy rather than a listed asset itself.

For example if I set the following:

image

And set the following sort order:

And set the page contents of the asset listing to:

<ol>
    <li>%root_nodes^as_asset:asset_name_linked%
        <ol>
            %asset_listing%
        </ol>
    </li>
</ol>

With the following asset map:

image

I get a frontend as:

image


(Tom Stringer) #17

Legend. That’s exactly what I’m after. I knew there must be a way to do it.

Thanks Bart.