Adding numbers to cms item by clicking a button

Hej, I hope this is the right topic for this Custom Code.

The Problem

I’m facing an issue with counting numbers in a cms entry including zappier.

The Idea

There is a number field in a cms item. When a person clicks a specific button in the item on the live page, the button should add 1 to the number in the backend cms item.

I tried it with zappier but it doesn’t work, since zappier can’t find the item, that the button was clicked in.

Is there a way to help zappier find the item in the cms backend of webflow?

1 Like

Hej, this is fixed now since the last update. We can now use the Item ID in Forms :slight_smile:

How did you manage to do it? How did you connect the button to the CMS number field and had it add one everytime the number is clicked?

Hej, what I wanted to do is adding like counters to CMS Items.

Webflow

First add a number field to your cms items called “Like Num”. That number can be shown on each CMS item by using a collection list in the template. Set it to zero.

Add the collection list to your CMS Item template to show the number on each item. Now add a form to the cms template and delete the text fields. Besides the Button you can add an html embed with the following code:

<input type="hidden" name="Item ID" value="choose from Button +Add field">
<input type="hidden" name="Post Titel" value="choose from Button +Add field">
<input type="hidden" name="Like Num" value="choose from Button +Add field">

In the Code you just choose the vars from your CMS Databank like you see in the “value”.

Zapier

From here on you can work in Zapier.

just add a form submission trigger and do the math (like num + 1) with a number action in Zapier.

After that you can post the new like num to the post with the “Item ID” that was also send by hitting the send button.

Let me know, if you have questions.

Thank you so much for answering! I am really new to webflow and just using it for fun so I’m going to try to do this and reply to you​:sweat_smile::sweat_smile:

Ok so I understand everything except the “coding” and “input” part. Can you please explain where I put this code and how I tell Zapier about it

Cool that you try it directly.

how I tell Zapier about it

Zapier knows by itself. Just try to trigger a Flow in Zapier by Webflow form submission. Than you can chose the form. There is also a training video from the academy about it.

where I put this code

You can add divs, images, forms, html embeds and so on. The Code needs to be placed in a html embed. You can check this video to learn about it.

Make sure to add the html embed into the form besides the button :+1

So I have multiple cms items each with their own collection page. And each has two button that will correspond to change different values would this work for that too?

You mean something like a thumbs up and a second thumbs down button? Since there are html embeds you can sure do that.

Please note that I’m a UX-Designer, not a Frontend Developer. Can’t help with code :wink:

Well thank you so much, I am neither lol. I’m just not figuring out what i need to put as the name and value for each one in the code

Do you want to share the project so I can have a look? You can send a view only link.

https://preview.webflow.com/preview/goodbad?utm_medium=preview_link&utm_source=designer&utm_content=goodbad&preview=f56143cfa102f375dbd614fa814cb0da&mode=preview

goodbad.webflow.io

Ok cool. Yeah, start with one button. You can add the second later.

So now you have 2 vote count numbers. In your CMS item template you should add the number field votes-up and number field votes-down. These are exactly the values you need to add.

Can you make it cloneable or accessible? Can only see the front end.

I can’t showcase website I dont have paid plan. What do I do lol
Or just tell me how the code would be with votes up and votes down
Also I just realized that I can’t embed code without paying… guess I can’t do it.
P.s I am really thankful for your help and am sorry to be bothering you

All good. My description above is detailed and seems to work. So we should check, what errors are coming up, when you try it.

  1. Don’t you need a paid plan to work with and publish cms
  2. What’s not working?