"Nested" shadow assets?


(Oleg Voronin) #1

Is it possible for a JSON data source (but really any data source asset would do) to *not* get flattened when mapped to shadow assets? For instance, if data is presented in a tree structure:

_item
 |_sub-item
 | |_sub-sub-item
 | ...
 |_sub-item
 ...
_another item
...

I'd like for it to be maintained when shadow assets are generated from it.


(Anthony Barnes) #2

You could consider not using the JSON data source at all (I believe you won't be able to get what you are looking for out of it). Another way to skin the cat would be to use the JS REST asset and process the JSON using server side JavaScript. This should leave you with the structure intact and you can basically output anything you like. It means the results won't be exposed as assets though.


(Oleg Voronin) #3

You could consider not using the JSON data source at all (I believe you won't be able to get what you are looking for out of it). Another way to skin the cat would be to use the JS REST asset and process the JSON using server side JavaScript. This should leave you with the structure intact and you can basically output anything you like. It means the results won't be exposed as assets though.

 

This is in fact the option I'm looking into now, but I have concerns on several levels from performance (parsing and processing a fairly large object whenever the page is accessed) to UX (GET action used for "navigation" within this tree structure).

 

Any advice on overcoming [preferably both] these issues?


(Anthony Barnes) #4

 

GET action used for "navigation" within this tree structure

 

The only way you could overcome this is if the JSON is a Matrix asset and you are 4.14.1+. There is a feature that allows you to preprocess Matrix keywords and that would allow you to use a global keyword to get the contents of another asset, thus avoiding the GET to an external source.

 

 

performance (parsing and processing a fairly large object whenever the page is accessed

 

I think the only other option here would be to use native PHP on the server to solve the problem. That would either be custom script or development to Matrix to allow you to produce the kind of output you want. If you are a Squiz client and want to customise like that there may be some SLA considerations, but you could also engage Squiz to do that kind of work for you.