The title can be in either text form or in a button.
I can get the button to link to a dynamic page like this:
but I can’t get it to wrap the text in the box.
I can add Text to the page, and Link part of the text, but I can’t get it to link to a dynamic page unless I SPECIFY the particular page (by title). I can’t get it to link to a Dynamic page based on the context of the link that they are clicking.
If you look at the two buttons here, you’ll see that they lose the right part of the text. The one on the left should say, “Bob Ross: The Art of Chill Game” and the next one should say, “Boss Monster: The Dungeon Building Card Game.”
Is there a better solution that doesn’t involve coding, or a fix for either of these coming?
In order to redirect the site visitor once he clicks on the text, you should use the to( ) function.
If you set the text based on a specific DB collection record, there’s a field with the page URL that you can use. In your case, it’s the “Games (Title)” column:
Hi,
Here’s a code sample to clarify what I were referring:
export function text3_click(event, $w) {
//Getting the current item of the collection
let itemObj = $w("#dataset1").getCurrentItem();
//redirect to the relevant dynamic page.
//"link-Games-title" is the name of the field where the URL is saved
wixLocation.to(itemObj["link-Games-title"]);
}
As you can see, I’ve created an onClick event for the text element and used the to( ) function to redirect to the relevant page after getting the current item of the collection.
I copied and pasted what you gave me, found an error about placement, so Ctrl-Z undid it, pasted it in a better place, and only got a warning. Went and changed the name of text3_click to text34_click and voila, it works great!
And see, I’m getting better at implementing code that you give to me. I’m not great at it yet, still takes some experimentation, but progressing!
I’ve got a very similar problem to this. I just can’t get the code to work even when I replace all the items with relevant data to my site (see the image).
The yellow warning says: Parameter ‘event’ is never used.
And the red error says: ‘wixLocation’ is undefined.
What am I doing wrong here? Should I paste the code somewhere else etc? I’m not really an expert with the code so any help you can give is much appreciated!
PS. I copied the “link-Tapahtumat-title-location” directly from the field key of the database column info. Also tried it without the “location” in the end.
and on confirm site is another button which will lead me to DP, but I’m still having the problem that the save button skip the save part and immediately link me to confirm site.
So can you explain to me how to at first save the data and after that link to DP or Confirm site, please?