Dynamic Drpdown Based on Metadata


(Nick Papadatos) #1

Hi

 

Is there a way to dynamically populate a unordered list based on metadata?

example: default format (search asset or asset Listing page)

<li>%asset_metadata_discipline_value%</li>
or
<li>%asset_metadata_discipline_key%</li>

The only problem is I only want this be added once i.e if there's multiple assets tagged "education" I only want education added once to the list.

 

Reason:

The list is based on many disciplines and I don't want to show any list items that haven't been tagged

 

functionality:

I have a filtered dropdown that filters assets using MixItUp plugin. I know I can hard code the list but for maintanence sake it would be great for it to be dynamic based on tagged assets (profiles).

 

assets: search asset, asset listing page (testing), MixItUp plugin, metadata schema and standard pages, paint layout


(Peter McLeod) #2

Hi 

 

Could maybe try using the asset listing but use custom grouping (and group by the metadata value) - and in the group format print the list item html and  group keyword (ie the metadata value). 

 

In the default (or type specific format) just have no content and set the container content to raw html. Not sure if you still need to include the asset_listing keyword in the group format section though (either way it won't print anything).

 

This should give you a list of unique metadata values.

 

Thanks

Peter


(Nick Papadatos) #3

Hey Peter, never crossed my mind to use group format, worked like a charm thanks :)


(Evan Wills) #4

I've been doing a bit of this lately in situations where grouping isn't appropriate, I use this:

%asset_metadata_discipline_value^notempty:<li>%%asset_metadata_discipline_value%%asset_metadata_discipline_value^notempty:</li>%

or

%asset_metadata_discipline_value^notempty: ^empty:<!--%<li>%asset_metadata_discipline_value%</li>%asset_metadata_discipline_value^notempty: ^empty: -->%

This second method works very well if you're doing a lot of stuff or have multiple keywords being rendered based on the value of a single keyword.

Note the use of both "^notempty: " and "^empty:...". If you don't include the ^notempty: with some white space after it, the keyword will render if it's not empty. Which is not so good.