Displaying multiple links

Hi,

I want to allow users to insert multiple links in a list of text-datafield. However, when I use the @link special function with this datafield, I get an error saying that the special function is incompatible with a list of text datafield.

What I am trying is this: @bullets(@link(#list-of-texts^datafield))

Is there a way to solve this issue?

Thanks in advance!

Same issue with emails in the @email special function.

This is fairly advanced stuff, so bear with me in the explanation!

The main problem is that @bullets expects a collection of something, while in your example you provide it with only one item: just one @link.

On the other hand, you do have a collection — all the individual pieces of text in the #list-of-texts^datafield — but when you would feed that collection to @bullets, it would put plain text (instead of hyperlinks) into each bullet.

So the solution is that you need to take your collection of individual pieces of text, but transform each of those pieces before you “feed” it to @bullets.

The way to do this, is through the @for special function. You can read all about it here. That special function takes a collection of individual items, and then transforms each individual item by feeding it to the internal snippet you specified, taking the output, and putting all the results back together in a new list.

image

In the example screenshot above, my sample input consisted of two plain pieces of text (test@test.com and alpha@beta.be). So the process is as follows:

First iteration

  • the placeholder ?ALPHA is assigned the first value of the list (test@test.com)
  • the software executes the internal snippet for that first value, replacing placeholder ?ALPHA in that snippet with its value at that point (test@test.com)
  • the result of that first execution is a hyperlink to email address test@test.com
  • that result is put into a new collection

Second iteration

  • Exactly same as the first step, but with the second value of the list (alpha@beta.be).
  • At the end of the execution, the resulting hyperlink is put into the new collection as the second element

Finally, the new collection (consisting of two hyperlinks) is fed into the @bullets function.

It worked, thank you for the clear explanation and example!