Link repeater to a url without using dynamic pages

Hi,

I have a collection with 6 categories which is displayed in a repeater. I use a collection because in the future there could be 9 categories or whatever. I want to link the image of those 6 categories to a specific url on my website that already exist, when the user clicks on it.

Using a dyanmic page wouldn’t work as those 6 categories have different pages with specific repeaters, etc. So it should be just a static url which is saved in the database.

Let’s say the database looks like this

Title link
titleA /a
titleB /b
titleC /c
titleD /d

I am using this code which works for repeaters. The code also works, if I save the full url [(XXX Sex - Free Porn Videos at XXX.com]((XXX Sex - Free Porn Videos at XXX.com) as an example), however opens a new tab, which I do not want. However ideally I would like to only save the extension (/a) and then if the imagine is clicked, we end up on the respective url without opening a new tab/ window.

here is my code:

import wixLocation from “wix-location”;

export function image6_click(event) {

let targetId = $w(“#dataset1”).getCurrentItem()[“link”];
console.log(targetId)
wixLocation.to(targetId);
}

Hello,

As stated in the API , you should be able to redirect your site visitors to a local link (a page on your site) like this:

import wixLocation from 'wix-location';

wixLocation.to("/about-me");

As for the second question, you can use link property and target blank in order to open the URL in a current window.

thank you! it works now. I had to format save it as string and not as URL in the database.

Actually, I still face some issues.

How can I use the getCurrentItem so that it actually gives me the url corresponding the the element clicked? At the moment, the new page is always the one of the first element, however obviously I want the url of the repeater element which is actually clicked.

This is the code:
export function image6_click(event) {
let targetId = $w(" #dataset1 ").getCurrentItem()[“link”];
console.log(targetId)
wixLocation.to(targetId);
}

I need to find the relevant row, however I am not sure how wix understands from the click, which of the repeater element is clicked and return the row numer. Any idea?

muito bom o eu estava com um problema assim em uma pagina que acessava e ela abria uma guia direto no https://xvideosamador.blog/ e eu não sabia oque fazer obrigada também eu não sabia como explicar!