Dropdown List by Group Name


(Nick Papadatos) #1

Matrix Version: 5.5

Hi Squiz Folk
I’m trying to use an asset listing page to populate a dropdown list based on a metadata value/s via custom grouping. Asset type to list => Calendar Event

The issue is that its populating everything but I need to only populate (dynamically update) values past or equal to today’s date?

PS - I know the below example is wrong but just wanted to show what I’m trying to do.

example:

  %begin_group_name^gte_date:{globals_date}%
       <option value="%group_name^lowercase%">%group_name%</option>
   %end_asset% 

This is probably simple but I can’t seem to work it out. I can hard code the dropdowns but that’s not a preferred option

Cheers
Nick


(Harinder Singh) #2

Try this

%begin_asset_updated^gte_date:{globals_date}%

You might have to change the keyword if you wish to compare with asset creation or published date.


(Nick Papadatos) #3

My bad Harinda that was a typo - it should have been %begin_group_name…% I’ll update my post.
I’ve also tried

     %group_name^replace_keywords:gte_date:{globals_date}:<option value="{group_name}">{group_name}</option>:%

The only way I can get this to work is using a calendar event search page - the asset lister shows everything

cheers
NickyP


(Harinder Singh) #4

What is you grouping by?


(Harinder Singh) #5

There is not much fancy keywords available at this level to control the behavior.

You can bind your values when you are grouping by using Keywords and then use SSJS to split them in the Group Level bodycopy.


(Nick Papadatos) #6

Grouping by metadata values - trying to create a dropdown values based on “region” (metadata) on future events not in the past. Easy using a event search asset but haven’t tried what you have suggested.

Cheers
Nick


#7

Did you get this sorted NickyP ?


(Nick Papadatos) #8

Hi bkelly,

No, not really. Any ideas welcomed :slight_smile:


#9

Depending on the number of events you have, the best bet is probably to spit out all events into an array, filter by date and then find unique values for region.

Asset listing (with no grouping) with json output of the necessary attributes for your events
eg. {“id”:"%asset_assetid%",“region”:"%asset_metadata_Region%",“datetime”:"%event_start_datetime%"},

Using ssjs (XXX is ID of asset listing)

<script runat="server">
    var events = %globals_asset_contents:XXX%;

    // filter array on date comparison, return true if event is in future
    var regions = events.filter(function(o){ ... })
    // reduce the array to region string
    .map(function(o){ return o.region})
    // and find unique values
    .filter(function(x,i,a) { return a.indexOf(x) == i});

And then print an option tag for each value in regions.
I omitted the date test function for brevity.
Actually, I’d imagine you could use a search page instead of an asset listing to filter the events. If so, then you would only need to output the region and use the last line to filter uniques.

eg:
[“North”, “North”, “South”, “Central”, “North”, “Central”].filter(function(x,i,a) { return a.indexOf(x) == i});
==> [“North”, “South”, “Central”]

HTH


(Nick Papadatos) #10

Thanks bkelly, appreciate your time looking into this - I’ll give your recommendation a go.
cheers
Nick