Asset listing order when nested using keyword


Matrix Version: v5.5.6.4

I have an asset listing the the order of which I control using query string. So when on the browser I go to it works as expected. Changing the sort_by and sort_direction will change the order accordingly.

However, I can’t seem to get it working when I use SSJS and keyword to nest this:


It gets me the assets listing content but not in the order that I want it.

Is that expected (not to work)? Thanks.

(Hugh McMaster) #2

The order of keyword operations doesn’t allow with_get to be used with global assets, if I remember correctly, because globals are always parsed first.

In saying that, I wouldn’t expect nested variables to work here, since asset listings are configured from a query string.

Have you tried something like:



Thanks for response… No I haven’t because I didn’t expect that to work … But I will try it and report back. Thanks.


It doesn’t work. And I forgot to mention that I don’t think the issue is with with_get used with global assets, because it works with other query string that I used to set dynamic root node, for example. It just doesn’t work with the sorting and sorting direction.


Has anyone come across this before and has got any solution? I would love to hear that. Thank you.

(Hugh McMaster) #6

Out of interest, why are you using SSJS? What does the rest of the implementation look like?


I don’t have to use SSJS, just it happens that it was implemented that way and I made some changes to it.

But I don’t think it is SSJS issue specifically here because if I nest the asset listing into another Standard Page using keyword, the query string for sorting by and sorting direction do not work either.

(John gill) #8

This one is fairly interesting, I’m not entirely certain what’s going on but:

  1. with_get definitely works with globals_asset_contents_raw

You can set up a simple example where you include an Asset Listing via a keyword and supply a get param then use that param inside the Asset Listing with %nested_get and see that it works.

Host page = %globals_asset_contents_raw:792^with_get:Param1=asd%
Listing (#792) = %nested_get_Param1%

  1. You can supply the sort parameters when using a Nest Content Container

If you pass the page_asset_listing_792_sort_by and page_asset_listing_792_sort_direction values in to a Nest Content Container the old fashion way, the sorting works.


  1. For some reason, those parameters do not work via with_get

When you try both at the same time, the sorting doesn’t work (as you observed). The parameters are definitely getting through, because you can check them with %nested_get_page_asset_listing_792_sort_by%, but the sorting just doesn’t happen.

%globals_asset_contents_raw:792^with_get:page_asset_listing_792_sort_direction=0&page_asset_listing_792_sort_by=3% :poop:

So we know we can pass values from keyword to a Nest Container, and from a Nest Container to an Asset Listing, let’s do something terrible.

  1. Create your listing with the asset sorting settings (#792)
  2. Create a shim page with a Nested Content Container (#813)
  3. Nest the listing in the shim page and set up two parameters to pass the sort_by and sort_direction through
  4. Lastly, use your globals keyword to bring the shim page into the SSJS in your actual page
<script runat="server">
    var source = "%globals_asset_contents_raw:813^with_get:page_asset_listing_792_sort_direction=0&page_asset_listing_792_sort_by=3^json_encode%";
    var source2 = "%globals_asset_contents_raw:813^with_get:page_asset_listing_792_sort_direction=1&page_asset_listing_792_sort_by=1^json_encode%";

This snippet includes the same listing twice with different sort settings.



  • You probably want to exempt both your Shim and your Listing from caching in Cache Manager, lest you ruin your day. Assuming the pages are never accessed directly this shouldn’t have any adverse effects.