(Resolved) display different ratings within repeater

Hi Stevo,
Thank you. I have tried to do what you suggested.

Please read 1st step first and then the second step.
My issue is that when connecting the ratings element in the repeater to supplier list, I don’t get the ratings connections that you get. Full details are below.

SECOND STEP

I then added the ratings to the supplier list repeater’s each container.

I added the idText text element (which I will make invisible with the same font colour as the container colour I assume?).

Please see below

I then connected the ratings display element to suppliers dataset.
However, I am not getting the overallRating and numRatings
as you do. My connections take me to review-stats columns which I added to Suppliers collection as a reference field.

This is my issue with this step.

how have you connected your memberProfile collection to overallRatings and numRatings here below?

end of the second step

FIRST STEP

On the supplier page itself.
I have added the text element with idText as field and added your code.
I also added on top import wixUsers from ‘wix-users’ as I did not have this in my page code.

end of the first step

Hi Stevo, I have not updated Page1 on the viewpoint enter on the main supplier page. What did you mean by ‘having an element to page 1’

If on the main profile page you have connected the star rating display to a dataset you need to disconnect it, and use code to populate the databases, also above the code i sent recently above that add another piece of code within a onViewportEnter event element, then use this code as well, (generalRatings) needs to be the ID name of the rating display element that you have. (this code will had 2 columns in the suppliers db named overallRatings and numRatings), then just connect the repeaters star rating display within the other dynamic page to these columns via dataset.

export function busName1_viewportEnter(event) {

let user = wixUsers.currentUser;
let userId = $w(‘#idText’).text;
let values;
const overallRatings = ($w(‘#generalRatings’).rating);
const numRatings = ($w(‘#generalRatings’).numRatings); #rating display ID
wixData.query(“Suppliers”)
.eq(“_owner”, userId)
.find()
.then((results) => {
values = results.items[0];
let Ratings = overallRatings;
let nRatings = numRatings;

let items = results.items;
items.forEach((item) => {
item.overallRatings = Ratings;
item.numRatings = nRatings;

             wixData.update("Suppliers", item) .then((results2) => { console.log(results2); 

});
});
}
)}

like this, so when the page is rendered by the browser and viewed by a user the onViewport element block of code runs

i just made a few edits to the posts above, so you might be able to understand it better

Addressing the second step of yours just tick these 2 boxes circled in red then they wont be seen, you don’t need to alter the font or colour

Thank you Stevio

Re: 1st step

you said:

Replying to Sammy

If on the main profile page you have connected the star rating display to a dataset you need to disconnect it, and use code to populate the databases, also above the code i sent recently above that add another piece of code within a onViewportEnter event element, then use this code as well, (generalRatings) needs to be the ID name of the rating display element that you have. (this code will had 2 columns in the suppliers db named overallRatings and numRatings), then just connect the repeaters star rating display within the other dynamic page to these columns via dataset.

The only star rating that I have on the main supplier page is with the reviews repeater at the bottom of the supplier page as per the Wix example.
So I am not sure which star rating you are referring to here.

In step 1 I only added the text element with the idText field.

I also understand that I need to complete the code on the main supplier page. My Step 1 was incomplete in terms of code.

I am understanding the step 1 better , thank you. I will give it a go.
Just did not understand the connected star rating.

Yes, of course, had not thought about the hidden and collapsed values for the elements. (:roll_eyes:to myself)!

So you have only 1 dynamic profile page with a repeater in it with ratings? And isn’t another dynamic page with a repeater in as well? I have 2 x dynamic pages, the main dynamic profile page, and another dynamic page elsewhere that lists all the company profiles and their ratings within a repeater

I only have one dynamic page for the suppliers list.
Please see my site menu below.

I did add another set of dynamic list & page for teachers but I have not used or touched it.

here is the site link. I dont know if I am allowed to invite you to my test site to see the code…

https://pt-tips.wixsite.com/website-1/suppliers

This is my main supplier page - only one repeater for reviews

I see now, I thought you had 2 x dynamic pages like me, the code I sent should still work.

Thank you So much, Stevo.
I have taken up so much of your Sunday!

I will do the updates in the next couple of hours and get back to you.
It’s amazing how much time goes into doing this!
Wix should really make things easier for users on this feature. (Wix I hope you are reading this :hugs:).

Sorry, I took a few hours away from the code as I needed to clear my head.

Question No. 1
I am just looking at your updated instrusctions, and at the first step I realise that on the supplier profile page - you have

Page Element with ID #page1

I dont have a ‘Page Element’.
My dynamic suplier profile page has section and stips elements, not a Page Element like you have.

Question 2

The supplier db/collection, you said it will have
overallRatings and numRatings columns.
Shouild I add these two columns to the supplier db?
And if I add this, where does its data come from?

Thank you

btw, just to avoid confusion, I also have two dynamic pages

  1. Supplier list (this is where I have the repeater to add ratings to each supplier in the list. I have called this Supplier Directory.)
  2. Suppliers (this is the supplier profile page)

No you don’t need to add the columns to the suppliers dB, the code should do this for you automatically when its run, providing you have read and write access to the suppliers dB, also by default every page has a page1 element, just click anywhere on the page background thats blank and it should pop up, it could be behind the strip, there is tool on developer console panel that allows you to search for a specific element. Use that to find it, if not and you can’t find it then just use the strip at the top you mentioned and put a viewport enter on it instead of the page1. But just alter the code ID to that of the strips.

Thank you

I have all these strips and sections that came automatically with the dynamic supplier profile page… I am unable to see behind them.

Please can you guide me on how to search for the page1 element?.

Ok sure click on tools at top right, select toolbar box option then all the way down on the toolbar to layers, that’s how you can pinpoint an hidden element. You don’t necessarily need to use the page1 element you can use any box or element at the top of webpage, because once a viewer opens the page that’s the first thing that is seen so onviewport it automatically runs the block of code and populates the suppliers dB with how many ratings there is. Then once the suppliers dB has the ratings in you can link a dataset upto the rating display element within the repeater. Just make sure there are two different viewport enters on two different elements at top of page, for both blocks of code I sent

@millwards322

Thank you for this Stevo, I want to give it a go later today or after you reply.
I have a couple of queries please.

To report back on the page1 element layer search

Please see the layers screenshot for another dynamic page (not used) on the website, it also does not have the page1

And this is from the actualSupplier profile page:
photo 1

Photo 2

Photo 3

Photo 4

I still can’t see page1 element :frowning:

When I went to rename a section element ‘page1’ it did not allow me and got error message that page1 is already in use.
So this tells me that it’s there BUT why can’t we see it?

Question 1.

Without going to the field Itself, can I activate the viewportenter event?

Question 2.

I looked through the additional code that needs adding and compared it with the one from 2020 that you have included.
I can compare it all except the bit highlighted in orange/brown bit below.
Is it supposed to be like this?
Also, I assume the busName1 will change to page1 ?
What about the “_owner” is this fine as it is?

export function busName1 _viewportEnter(event) {

let user = wixUsers.currentUser;
let userId = $w( #idText ).text;
let values;
const overallRatings = ($w( #generalRatings ).rating);
const numRatings = ($w( #generalRatings ).numRatings); #rating display ID

wixData.query( “Suppliers” )
.eq( “_owner” , userId)
.find()
.then((results) => {
values = results.items[0];
let Ratings = overallRatings;
let nRatings = numRatings;

let items = results.items;
items.forEach((item) => {
item.overallRatings = Ratings;
item.numRatings = nRatings;

  wixData.update( **"Suppliers"** , item) .then((results2) => {  
  console.log(results2); 

});
});
}
)}

Question 3

If I were not to use page1 element.

then you are saying that I have two elements (box for example), box1 and box2

The two codes are code no.1 and code no.2

In box1 :
I include the
Code no.1
Code no.2

then again in box2
I include:
Code no.1
Code no.2

Do I also hide box1 and box2 ?

Thank you!