Help with linking to a Dynamic pages anchor

Hi guys as above im trying to link a button from one dynamic page to another dynamic pages anchor with code but as to match the members id , any ideas?

Iv’e tried this but doesnt work…

export function reviews_click(event) {

wixLocation.to(`/anchor1/${wixUsers.currentUser.id}`);  

}

 wixLocation.to(`/${pagePath}#${anchorPropertyId}`);
1 Like

Hi J.D thanks for your quick response however this doesn’t work buddy

@millwards322 you have to define the variables first. Something like:

let pagePath= 'members';//use your own destination path
let anchorPropertyId = 'anchor1';//use the anchor id
wixLocation.to(`/${pagePath}#${anchorPropertyId}`);
1 Like

@jonatandor35 hi this does work now but only for a logged in member, if im not a member and therefor not logged i click the reviews button and it goes straight to a 404 page, but if i’m logged in it works, how can i make it work both ways logged in / and logged out, this is the code i’m now using

export function reviews_click(event) {

let pagePath= Updatedmemberprofile/${wixUsers.currentUser.id};//use your own destinatio npath
let anchorPropertyId = ‘anchor1’;//use the anchor [id](id
wixLocation.to(/${pagePath}#${anchorPropertyId});
}

Thanks)
[wixLocation.to(/${pagePath}#${anchorPropertyId});](id
wixLocation.to(/${pagePath}#${anchorPropertyId});
}

Thanks)
[}](id
wixLocation.to(/${pagePath}#${anchorPropertyId});
}

Thanks)

Thanks again bud

@millwards322 you’re trying to redirect the user to his/her own member page , but as long as they’re not logged-in, they don’t have a member page (because they’re only site visitors, not site members). So of course they’ll get a 404 page. What would you like to present in this case?

I see, yes i want a site member to be able to navigate to another dynamic anchor page too, as well as a non site visitor, this is a screen shot of a members profile where a visitor can view and also a logged in member can view too, i want them to be able to click the reviews button and be navigated to a anchor on the My Profile tab page

thanks

Dynamic page based on member id is for members only. You can’t have it for random visitors.

@jonatandor35 Hi buddy thats the way i’ve actually set up my website lol it all works nicely, i’ve set it up in this way because of database permissions etc if you go onto my website and click search by company name then type M&M click onto that profile then click gallery and then once on that page click the reviews tab next to background checks, then you will kind of see what i’m trying to do, would it be best just to do a wixData.query on the members db instead?

lwebsite link https://millwards322.wixsite.com/hiretrades

@millwards322 I’m not sure what exactly you did there.

@jonatandor35 hi J.D i know it’s a very complex site lol i have still got lots of work to do,

go back onto the site and click trades login up top and login to this test account, once there click my account up top then click my profile button, it will work this way as your logged in, but will give you more of an idea what i’m trying to accomplish, thanks

tes—t@test.com

pass: steves2

@millwards322 what I meant is that I don’t know what you did under the hood. How you created the dynamic page, what filed you used for it, what code you used.

Have you got an email then i can add you as a site contributor then you can see all the code under the hood for the Updatedmemberprofile/MemberProfile page and the dynamic gallery page,

Sorry, but I just don’t have time to look at other people editors (I have my own site to build).
But maybe you can describe shortly, what you did and what you’re trying to achieve, and then we may be able to advise.

@jonatandor35 Hi thats fine, no worries there thanks, and i hired a guy off here not sure if you know him, david at sk media, he implemented a repeater slider on the home page where visitors can click on recent reviews and it takes them direct to there profile page he used this code, i need something similar to this snippet because it works logged in or out, but doesn’t work where i want it to

function links(biz) {
wixData.query(‘MemberProfile’)
.eq(‘traderBusinessName’, biz)
.limit(1)
.find()
.then(im => { wixLocation.to(im.items[0][‘link-Updatedmemberprofile-traderBusinessName-_id’]); });
}

@millwards322 so let’s ask @skmedia

1 Like

@jonatandor35 he is probably fed up of me by now lol he had trouble completing a notifications bar we agreed a quote on, so think he as given up lol

@millwards322 Not fed up, just busy! To link to an anchor, you would need to link to the site using a url query. In the dynamic page’s onReady, check to see if the query is present, and if it is use scrollBy or scrollTo to go to the desired location on the page.

https://www.wix.com/corvid/reference/wix-location.html#query