Clickable email-me or call-me buttons generated from the CMS?

Question:
Can anyone tell me how to create clickable call-me and email-me buttons from data in a collection?

Product:
Wix Studio Editor

What are you trying to achieve:
I am working on a website for a real estate company and want to link the agents’ phone numbers and email addresses to clickable buttons. The agents’ information is populated from a collection.

What have you already tried:
I have read through the Wix help articles and watched a lot of YouTube tutorials on this, but no success.

Additional information:
The lack of information out there tells me that I am just overlooking something obvious. I would appreciate any help you could offer.

mailto:address@example.com and tel:+15554441111 are the types of links you want

To populate those links in buttons, it’ll depend on how you’re accessing the dynamic data

But let’s say you already have your dynamic data
For demonstration purposes, let’s say it’s:

itemData: {
    phone: number,
    email: string
}

To populate them as button links:

$w('#emailBtn').link = 'mailto:' + itemData.email
$w('phoneBtn').link = 'tel:' + itemData.phone
1 Like

Dean, thank you for your quick reply! I am working to implement your solution on the site now.

Hi @DeanAyalon ,

What what would you recommend for a large dataset of 60? This dataset will fluctuate in quantity. Will each button need to be separately assigned?

DRY is a an important concept in programming, meaning Don’t Repeat Yourself

The elements are linked to a dataset by appearing in different items of a repeater, right?
Assuming an email is specified in a field called email

$w('#repeater').onItemReady(($item, data) => {
    $item('#mail').link = 'mailto:' + data.email
})

Thank you for the quick reply!
Do I place this code in a CMS field?

No, that goes in the page code
You can enable it in the toolbar on the top of the editor

1 Like