Embed hyperlink in text box inside repeater.

I am trying to embed a hyperlink in a text box that is inside a repeater. It needs to link to the URL section of the database. When I try to connect the text to the database, I have only one option–which is to connect to the “title” data. There is NO additional option to link that “title” text to the “URL” section.

How do I embed hyperlinks in text while connected to the database? The images allow a link to the urls in the database–but not the text boxes?

It’s silly to NOT have clickable text that is connected to the database…I hope I’m missing something!

you will need to use a button and customise it so it looks like text

1 Like

tried that…and you only get one line of text…it does not reflow. i need longer text that uses url from database. crazy that this ia an issue. help!

3 Likes

Hi Lunden,
You can add onClick event to the Text element.
It should look like this:

import winLocation from 'wix-location';

$w.onReady(function () {	
	$w('#yourRepeater').onItemReady((selector, itemData, index) => {
		$w('#YourTextElement').onClick(() => {
			winLocation.to(itemData.url);
		});
	    });
});

Don’t forget to connect the Repeater to the database collection and to create a field of URL.
Good luck!
Roi

2 Likes

Thanks Roi…but I’m not a coder…here’s a screen shot of the code section when I hit the plus sign in the “onclick” panel. The repeater name is “#repeater4” and the text box inside the repeater is called “#text52

The dataset is name “UNCENSORED” and the column head for links is “[url]” (note wix added the brackets when I entered the column name. Can you show how code should read and how to insert?

Hi Lunden,

The feature that you wish requires coding.
You can hire an expert in Wix Arena .

I"m not sure i understand your question. What do you mean by “Can you show how code should read and how to insert?”

Roi

Hi Roi (or Lunden, if you’ve had success with this),
I am also trying to link the the text in my repeaters to the “link” field in my database. I have put in this code you suggested, and it sort of works, but all of the repeater boxes are linking to the SAME one link (for some reason it’s the last item in my database). Do you have any idea what I’m doing wrong and what I need to tweak to get them all to link to their correct url?
Is there some other part of the text I need to change? Here’s what my code looks like:

import winLocation from ‘wix-location’;

$w.onReady(function () {
$w(‘#repeater1’).onItemReady((selector, itemData, index) => {
$w(‘#ArtistName’).onClick(() => {
winLocation.to(itemData.link);
});
});
});

Any advice for a total beginner very much appreciated.
Thanks!

Hi,
Try to change winLocation to wixLocation
Roi

Thanks Roi, but nope, that doesn’t do it. Any other ideas?

Hi, can you please share a link to your site and specify the name of the page so we can inspect ?
Roi

How about a clear/invisible button over the top of the whole thing?

good sir, i have one doubt that how i connect phone number link to repeater button. how to set the data base . any one help me , please transfer the code.

For anyone arriving here looking for an easy solution that doesn’t involve coding:

  • In your database collection, locate the text field that you want to have a link

  • Set the text field type to ‘Rich Text’

  • Click on the text inside the field and highlight the portion that you want to be a link

  • A toolbar should appear with all the normal text editing options, including the link icon

  • Click the link icon and insert the URL that you want to link to

3 Likes

Old post I know, however the error you have got here is that you have a non-structure field in your dataset. it was marked with a [fieldname], however, now it is shown as in this support page here.
https://support.wix.com/en/article/about-the-structure-of-your-database-collection#non-structure-fields