Static array

Hello Wapplers,

I have pretty simple idea but cannot realize it in a proper way.
I would like to have a local (hard coded, data is **not from DB) **array with pre-defined values and then interact with it.

For example: list of phrases which I wasn’t to show randomly (.randomize.top(1)) in specific user actions.

What would be best approach to achieve this?

You can store the array in a variable, eg:
<dmx-value id="var1" dmx-bind:value="['dog','cat','lion']"></dmx-value>
… and get the random value as in your example:
{{var1.value.randomize().top(1)}}
(but you omitted the first set of brackets).

To sort this array, you could use:
{{var1.value.sort($value)}}

4 Likes

Thank you so much! Works like a charm!

1 Like