Adding a rating to a dynamic index

Hi there,

I have a databases of companies stored in collection, and i create a dynamic index/directory list in one of the website pages. So when ever i add a company to the database it’s automatically added to the same page with the same design.

I want to add a user rating input and display, so users can rate each company.

Have read the wix code guide on how to add a rating input to a static page. But couldn’t find how to do that for a dynamic one.
I assume that the code needs to create a new database collection automatically on each new company i add to the collection, so the rating value and number will be stored somewhere.

Am i getting it right?
Does someone have some tips on how to do that?

Thanks!

1 Like

Please share the url to your page. My guess is that you are missing the point that a dynamic page is automatically created for you with a pre filtered dataset for your data collection. You shouldn’t need to create a new data collection if you have already specified the day collection and field that the dynamic page is driven from. If you look at the data collection your page is based on you will find one or more columns that have field keys ‘link-’. This is the filter used by the wix engine to load the page and filter the row it gives you.

Hi steve,

thanks for the prompt reply.
i guess i am missing a point ir 2…
here is the page link:
https://www.happybarefoot.com/minimal-barefoot-shoes-directory

Also i’m not sure about the columns you mentions, here is a screen shoot:

@barefootexpert HI There:

OK There is a page type called Dynamic Page. Here is the documentation you need to check out:
dynamic pages

With dynamic pages you create a page that can be loaded based upon the row of a particular database that you are interested in.

When you create a dynamic page you identify which data collection property it will be driven by:


In the above example The dynamic page is dependent upon the Stores/Products data collection and the value of the slug column.
When you create the dynamic page a new row is added to your data collection that references the selected data collection and property. It looks like this:


Note: the value of each column row is the link you can give to the wixLocation.to() API call which will prepare the dynamic page and filter the dynamic dataset for you before it loads the page. You access the value using the field key for the column which you can get from the Data Collection page:


So once you have the row you need from the data collection you can get this value and navigate to the dynamic page.

import wixLocation from 'wix-location'; 
import wixData from 'wix-data';

$w.onReady(() => {
    $w('#someDropDown').onChange(loadDynamicPage);
}

function loadDynamicPage(event) {
    let dataCollectionRowKey = $w('#someDropDown').value;
    wixData.query('MyDataCollection').eq('keyColumn', dataCollectionRowKey)
    .then((result) => {
        if (result.length === 1) {
            // Success
            let theRow = result.items[0];
            // Get the link field
            let pageUrl = theRow['link-Stores-Products-slug'];
            if (pageUrl) {
                // We have a link!
                // Load the dynamic page
                wixLocation.to(pageUrl);
            } else {
                console.log("Missing a dynamic page link");
            }
        } else {
            console.log(`Missing or too many matching records for ${dataCollectionRowKey}`);
        }
    }
}

Hope this helps!

wow steve, your the best.
thanks for the super detailed reply!
i’ll try it out.