Inserting value from the CMS field into custom code

I have several store locations where each location has its google reviews.

I have implemented a code I found online which lets me pull reviews from Google places and display 5 of them on a page. However, the code uses a static, hard-coded ID of the store location.

Click here to see it.

I need to make this solution dynamic by using CMS template and place IDs sourced from the CMS item.

I have placed the script in the stores’ template page, and now I need the location ID to be pulled from the store CMS field and placed into the script.

You can take a look at the code located in the Saloni Template
The Place ID code is located in the field named Place ID

Here is my site Read-Only

While at it, maybe you can tell me why I can only get 5 of them. I don’t see any parameters in the script indicating this value. Is this set up elsewhere?

Thank you very much

@memetican, maybe you have time to look at this one for me as well. Thank you very much.

@Roadhat - would this not work?

image

When you say you are limited to 5 what do you mean?

1 Like

As Sam showed, in a CMS Collection page, you can insert variables into your page custom code as well, just like you can in an HTML Embed. It’s the + Add Field link in the top right corner.

image

Make sure to put "quotes" around your value, it won’t be quoted automatically.

Limited to 5… I don’t see anything in the script itself, you’ll want to check the google APIs docs for that call and see if there is a way to specify that you want more.

For what it’s worth, if you use Zapier or Make, you might prefer to use automation to collect your reviews into the CMS, and then serve them from there. That way you can use Webflow’s built in Collection Lists and databinding rather than minting HTML in your script. It also lets you do thing like sort the best ones at the top, filter out any low ratings, randomize the sort, etc.

1 Like

Thank you so much @sam-g and @memetican !
This is amazing hos simple the solution was :slight_smile: yet I was nowhere close to a solution on my own since I don’t know JS syntax and had no idea one can use tags there as well. Yet, using copy-paste and some logic, I manage to get places with it. However, in situations like this, I depend on your help. So I am very thankful you are taking time to do this.

Thank you both again!

@sam-g by limited to 5 I meant it pulls only 5 reviews although there are many more.

@memetican this approach is a short-term solution for meeting the deadline. I plan to do as you suggested. On top of the benefits you mentioned, I am not sure how Google looks on what I am doing.
I have tried using Zappier on two occasions with products and have run into issues. Maybe I should start with something less complicated like this list :slight_smile:

My next challenges are finding why the reviews all showing in English if they were natively written in Croatian, and why only 5 of reviews are being pulled.