I’ve constructed this %asset_sibling_prev^as_asset:asset_url_path^contains:{asset_url_path^explode:/^index:2}:1:0% but it only returns false (0) even when:
the previous sibling is /foo/bar/baz
the current adjacent asset is /foo/bar/bla
I’ve also tried %asset_sibling_prev^as_asset:asset_url_path^explode:/^in_array:{asset_url_path^explode:/^index:2}:1:0%
I kept going and I’ve come up with this %asset_sibling_prev_type_1^eq::1:0% in SSJS as I think you’re right, what I was doing before was always evaluating to true.
The above is used to determine whether the asset listing has changed group, for example:
Foo
Shadow asset
Page 1
Page 2
Bar
Shadow asset
Page 3
Page 4
I found that the code I was using previously was returning the shadow asset, which happens to always be Type 2 by default. The above code checks that the %asset_sibling_prev% is looking at a Type 2 asset. If it is, I can imply that Page 3 (for example) is at the top of that group (Bar) and so I can print Bar on the screen and open a list list item tag to enclose the next two pages and so on.
I tried using grouping in the asset listing which worked perfectly but always listed the groups in an odd order, despite different attempts to get it to list in the order assets appear in the asset map.
The approach I’m using now works, just gotta figure out how to wrap the HTML and open/close the tags right so they appear correctly to the user.