Good evening guys,
I would like to add a comment section on my dynamic page but if I use some of the comment apps there will be the same comment on all of my dynamic pages.
What can I do to show different comments on each of my dynamic pages?
Thanks for your response!
you dont need an app. Just use a repeater connect it to your comment database and filter the dataset for items only related to that particular dynamic page
We have an example how to do so. Look at the tips forum cateogry
Dear Mike,
Can you kindly provide more information about this. I am new on Wix, and not familiar with any coding, so please provide me with more information on how I can do this, the more information the better
Thank you very much for your help and time.
Regards,
@ourprojectaf
import wixUsers from “wix-users”;
$w.onReady(function () {
//place a post comment button on the page and call it commentButton1
$w('#commentButton1').onClick(function () {
//dataset1 is connected to your collection where you store the original post
let orininalPostId = $w("#dataset1").getCurrentItem()._id;
//dataset2 is connected to your collection where you store the comments, make sure you have set read/write access to dataset2
$w("#dataset2").onReady(() => {
let user = wixUsers.currentUser;
//get userEmail so that it can be passed to the comments database that way we know who made the comment
user.getEmail()
.then((email) => {
let currentUserEmail = email;
//create columns in your comments database and name them orininalPostId, comment, userEmail. Place an comment input box on the page and call it commentInputBox1
//now we save the comment to the database
$w('#dataset2').setFieldValue('orininalPostId', (orininalPostId));
$w('#dataset2').setFieldValue('comment', $w('#commentInputBox1').value);
$w('#dataset2').setFieldValue('userEmail', (currentUserEmail));
$w('#dataset2').save()
})
})
})
})
@mikemoynihan99
Thank you very much for your help and time.
I have done this, but an error with
let orininalPostId= $item(“#dataset1”).getCurrentItem()._id;
it says: “$item” is not defined."
Can you kindly help me t fix this?
Thank you again,
Your help and effort will surely be approaciated.
Regards,
I can’t seem to find example on the tips forum would you be able to post a link?