Learn how to use the Data API function to create a comment system for your Wapka website.
Data API is useful for creating complex systems.

Written by on · Updated on

Having a comment system is extremely useful as it allows your users to interact better. Therefore, in this article I will show you how to use the Data API function to create a simple comment system for your posts, which will also allow you to understand how the Data API works and how it can be used in other situations.

Basic setup

Let's start by creating a new page called post, which will display a single post from your blog/forum. On that page, add the following Post Lister function:

  • Code:
  • Config:

Still on that page, add the following TAG code (placed at the end):


Adding the comment form

Now, we can start using Data API. Still on the post page, add the following API Data Creator function (placed at the end):

  • Code:
<p>Add a new comment.</p>
<textarea name="comment_message"></textarea><br/>
<input type="submit" value="Add comment">
  • Config:

See how the KEY/VALUE pair is used? You can use this to create other form fields or variables. Unfortunately, you can only use up to three KEY/VALUE pairs.

The PID configuration is used to identify which specific resource the API Data is related to. It can be a post ID, a file ID, a user ID, or a page ID.

The CATEGORY configuration can be the following options: file, folder, page, forum, post, user. That means you can create different comment systems for your files, pages and users!

Displaying the comments

The final step is to display the comments. Still on the post page, add the following API Data Lister function (placed at the end):

  • Code:
<h4>Reply #%id% by %username% at %date%</h4>
  • Config:

Here, %value1% will display the content of the KEY comment_message (%key1%).

After creating some comments, the API Data in the Wapka Dashboard will look something like this:

API Data example.

Final considerations

As you can see, it's relatively simple to use the API Data function. Feel free to leave a comment below with any questions or suggestions for this post.