Pick an item from a listing using keywords

Hi folks

If I have an asset listing whose id is 12345 and i want to display the 5 item in the list using keywords how do I achieve this?

When I use
%globals_asset_contents:1069075^as_array^index[3]%

I get the entire content plus the name of the asset

thanks in advance

paul

You can achieve this via SSJS

<script runat="server">
    const assets = %globals_asset_children:159767^as_asset:asset_name,asset_type_code,asset_url^empty:[]%;
    if(assets.length > 1){ 
        const fifthItem = assets[2]; 
        print('<a href="' + fifthItem.asset_url + '">' + fifthItem.asset_name + '</a>');        
    }
</script>

If you only want to achieve this using the Asset Listing, you can set up a new Asset Listing and create a Position Format for the body copy.

Enter 5 as the position number to display the 5th item. I think this should do the trick for you.

Make sure all other bodycopies are empty.

Hi Harinder

Sadly, this did not work for me but the ‘position body copies’ might - thank you for your help :slight_smile: