How To Use Server Side JS & Keywords to List Assets


(system) #1

In this tutorial, we're going to use a very basic example of adding some SSJS code to a Paint Layout that simply lists the child assets under the page that the layout is applied to.


This is a companion discussion topic for the original entry at https://matrix.squiz.net/a?id=13652

(TT) #2

Good example! I like using ssjs to keep everything in the one asset (paintlayout) rather than having to nest in other assets (asset listings/search pages etc.)


(Tbaatar) #3

Nice example.

As mentioned in the article SSJS shines for relational listing. If you are doing a simple asset listing you are probably better off with a normal Asset Listing asset as it will give you a good amount of configurable options and anyone picking it up will understand it.

I find it is lot cleaner to create a component for the SSJS or Asset Listing asset and bring into your Pain Layout with the global keywords e.g %globals_asset_contents_raw:1234% as opposed to writing SSJS in Paint Layout or creating a div and to nest Asset Listing.