Image = Dynamic Link

Hi all,

On a dynamic page I am trying to create a link to someone’s Facebook page. I’ve uploaded a photo of the Facebook Logo and now want to link it to a URL in a database. Does anyone know how to do this or can anyone point me in the right direction in terms of the coding? Should be fairly simple but I am by no way experienced at this!|

Thanks

Hi Joe,

I suggest you to add a new filed at your collection that include the URL, so each person at the collection will have a facebook photo and a URL.
At the page site of your dynamic page add an onClick() event handler that run when the user’s clicking on the image. At the handler use getCurrentItem() function that returns an object that include the current person’s details from the database.
Get from this object the URL field value and navigate to the URL.

for example:
wixLocation.to(“result.items[0].urlField”);

  • Pay attention ,a dataset needs to load its data before you call its getCurrentItem() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. So if you call getCurrentItem() inside the page’s onReady() event handler, the dataset might not be ready yet.

Here you can read more about this function.

Best,
Sapir