Creating a dynamic link for dynamic member pages

I have several dynamic pages, approximately like this:
grades / student1email
grades / student2email

Each of my site members (a student) has a ‘Grades’ link in the non-dynamic member area, but I can’t make it work with my dynamic pages. What should I do to make the link lead to different pages, depending on who clicks it?

I tried putting link like this, but it didn’t work: mysite / grades / {Email Login}

Г-жа Жильцова, рассказывайте, что у вас там за проблемка?

Did i understand you right?
You want to assign each Student a to dynamic page?

Ok, let us reconstruct a little bit your situation.

  1. You have a database right?
  2. In this database you have several references/columns (grades/email/student or something like that).
  3. Do you use datasets?
  4. Do you use coding?
  5. perhaps a little pic of your project to imagine better your situation?

I could help you to generate a code for this behaviour, but it could be a little bit another way to the same solution.

I assume the student has to login to get to the grade page, you probably need some code in the onClicks handler of the button. Something like the following

import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;

function toStudentGrade ( student) {
let studentEmailAddr;
student.getEmail()
.then( (email) => {
studentEmailAddr= email;
} );
if ( student . loggedIn ; ) wixLocation.to(grades/+${studentEmailAddr});
}

$w.onReady( function() {
let user = wixUsers.currentUser;
$w(“#buttonID”).onClick( () => {
toStudentGrade( user);
} );

Thanks!

I put in this code (of course put the full link to grades), but I’m getting an error saying " Wix code SDK error: fulllink/grades/+undefined is an unsupported url"

What could be the issue?

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

function toStudentGrade (student){
let studentEmailAddress;
student.getEmail()
.then((email) => {
studentEmailAddress= email;
});

if (student.loggedIn)
wixLocation.to(grades/+${studentEmailAddress});

}

$w.onReady( function () {
let user = wixUsers.currentUser;
$w( “#button12” ).onClick( () => {
toStudentGrade( user);
});
})

Okay, may be it is a timing issue of the promise, how about:
student.getEmail()
.then((email) => {
studentEmailAddress= email;
})
.then(() => {
if (student.loggedIn) wixLocation.to(grades/+${studentEmailAddress});
})

Hello :slight_smile:
Here are some screenshots.
This is student’s member area. A student can see it when he logs in. The button ‘Classes Balance’ is the button we are interested in. When student clicks on this button, he should be redirected to ‘website/grades/studentemail’ page

This is what the Grades page looks like. There are about 5 tables or so, all of them are in collections/datasets. It is a dynamic page, it shows different class balance, courses, grades, payment links depending on the email of the student. The URL is ‘website/grades/studentemail’


Now the only thing I want is to get the student from member area to this page, and make sure the student sees only relevant to the profile information :slight_smile:

To answer your questions:

  1. You have a database right? - Yes, for the ‘Grades’ page
  2. In this database you have several references/columns (grades/email/student or something like that). - Yes
  3. Do you use datasets? - For the ‘Grades’ page. Tried to do it for the member area first, but it didn’t work. The way it works on the Grades page is great :slight_smile:
  4. Do you use coding? - Tried code from the the answer suggested below for this question. Apart from that no.

Спасибо :slight_smile:

Thanks! It works and doesn’t work at the same time.
It’s giving the right URL, but when I click, it says ‘unsupportedURL’. When I type the same URL in the address bar, it works.

Can you try : /grades/+${studentEmailAddress});
instead of grades/+${studentEmailAddress});
That is according to :
https://www.wix.com/corvid/reference/wix-location.html#to

  • Regular page: See the SEO tab of the Page Settings panel.

  • Dynamic page: See the Page Info tab of the Page Settings panel for the URL structure. The actual URL used for navigation needs to contain values where the placeholders are.
    For example, if the URL structure of your dynamic page looks like:

and you have an item with the title “Waffles”, the local URL to that page is /Recipes/Waffles.

By the way, what is the student email address look like, may be there are special character like @ … that is not supported by wixLocation. to().

I wait a little bit with my posts, i am sure ayleung66 will solve your problem.
(он сможет решыть вашу проблему, ну а если нет, тогда я подключюсь.)

This is awesome, now it works as intended. Thanks a million!
I also thought it might be the @ symbol, but turns out it’s just fine :slight_smile:

Спасибо, решили! Thanks, it is working now :slight_smile:

Good to hear, here is the final version that is cleaner:

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

function toStudentGrade (student){
if ( ! student.loggedIn ) return;

student.getEmail()
.then((email) => {
wixLocation.to(/grades/+${email}) ;
});
}

$w.onReady( function () {
$w( " #button12 " ).onClick( () => {
toStudentGrade( wixUsers.currentUser );
});
})