Adding a comment box on item's pages

1- Yes, simply add a text element to the repeater and connect it to “Date Created”
2- Yes, set you comments collection’s permissions as “Members only” in “who can create content for this collection?”. You need to go to your collection, then click on “Permissions” in the toolbar.

Thanks, Tristan

  1. Ok, but what if I want the data (user name, avatar image) of logged-in users to automatically attach to the comments. How can we connect the member’s page data (I use the new Members Area feature by Wix) to the comment box? I see that Jakub did this, so I guess it’s possible. Can someone share this code with me?

Hi Jakub,
Can you please share the full code that you use

PLEEEEEEASE, can someone make a detailed video tutorial that will explain to us how to add this comment feature to the site. I’m sure that many people will be most appreciative.

@code-queen, where are you?

Hi Andrew,

1 - set up your database like on picture below:


Jmeno = nick or name
Komentar = comment
foto = foto of the author which comment the photo
reference = id

2 - set dataset permission for: Anyone
3 - use this code:

import wixData from "wix-data";

export function KomRead_ready() {
		
		let filter = wixData.filter();
			filter = filter
			.eq("reference", $w("#input2").text);
			$w("#KomRead").setFilter(filter);

}
	
export function KomWrite_ready() {	

		$w('#KomWrite').setFieldValue('reference', $w('#input2').text); 
		$w('#KomWrite').setFieldValue('jmeno', $w('#input3').text);
		$w('#KomWrite').setFieldValue('foto', $w('#image74').src);
		
}

export function save_click(event, $w) {

		$w('#KomWrite').setFieldValue('reference', $w('#input2').text); 
		$w('#KomWrite').setFieldValue('jmeno', $w('#input3').text);
		$w('#KomWrite').setFieldValue('foto', $w('#image74').src);
		$w("#KomWrite").save();
		$w("#KomRead").refresh();
		
}

4 - Set up 3 different datasets on your comments page

  • KomRead - leads to your Comments Database - set it up for read only

  • KomWrite - leads to your Comments Database - set it up for write only

  • Members - this dataset must be filtered as - Owner is Logged-in user


5 - Every one of those 3 datases must be connected to onReady function and have specific ID that you will use in code:


6 - Connect your nick and foto to Members dataset where you pull out your foto and your nick


7 - In all comments section connect foto and nick to KomRead dataset (read only dataset)

I believe that I gave you all necessary instructions you will need.

If you have any questions please read all comments section if anyone of us did not write it here. It’s already quite a big discussion with all necessary tips thanks to Mert and Tristan.

Don’t be a worry to play with the code as you wish and don’t give up.

Happy coding,
Jakub

That looks very interesting, something I’d like to have on my website (members content only), can you share your website please ?

By the way, my website is now live !

You can check it out here : https://www.wehaveadeal.net/

I know there are performances issues, but hey, we’re building under Wix…

Hey Tristan,

How did you implemented the search box in your website? Is it a app from wix app store or did you wrote code fo it? Thanks.

Nithin

Nithin : yes it’s the search app from the store, I wish I had a custom search box to search all collections and show items found on a result page, but apparently it’s not possible :confused:

Thanks Jakub, actually I’ve already watched videos on how to set up a member’s page and all, the only thing is that it doesn’t really suit my needs, as I want users to have a unique username.

Nope, it’s not. You can add your own search box only for 1 database. It’s not possible for now to search all databases.
About that unique username, I’m having the same problem, but I just start looking for it. So if I will find any solution I will let you know. :slight_smile:

Hey guys,

I don’t know what the hell happened but all of a suden users can’t post comments anymore !

Ouch, sorry to hear that. Can’t see the problem and everithng work well for me.
Did you try to debug the code?

Nothing shows in the console :frowning:

Whats wrong in my code???i m totally got crazy…

@dubeyabhishek313 Check page 4. There is a step by step guide.

Hi, Amit. It doesn’t work for me.

#dynamicDataset
What is it?

@tristan-breon Hi Tristan. How did you get the number of comments? Can you share the code?

Hi, guys. I tried to create comments following your instructions here and it works perfectly. But I want to add a little more functionality. I want logged in users to be able to liking comments. This guy made great code for a repeater, but that doesn’t work for me:
https://www.wix.com/code/home/forum/community-discussion/liking-posts-in-repeater-comprehensive Any ideas how we can integrate this?

Hi there everyone! I have successfully created comment box for my website .Its working all perfect with comment count too. I am adding like button to my comments too !
Here is my website : https://www.gigabytegaming.net/pc-games
(OPEN ANY GAME)
ANYONE WHO NEEDS THIS TYPE OF COMMENT BOX, PLEASE REPLY HERE !
Added captcha for verification too !