Skip navigation

PHP JUGNOON jComment Documentation

Overview


jComment is a professionally written jQuery and PHP script which allows you to implement advance comment posting feature with any type of dynamic and static records within your php website easily using few lines of configuration codes.

View details »


Change Log

Current version of jComment script is 1.0.0. There is no change log, bug fixes or update reports available yet.


Framework

Jugnoon Membership Kit has been used as core script for providing a back bone for jComment script demonstartion. You can use your own solution for it.

View details »


What's Included

Core files related to jComment script located in jcomments folder which includes.


root/
├── jcomments/ (root folder)
├──── css/ (few css styling files located here)
├──── img/ (default loader or avator image)
├──── security/ (optional csrf protection related files)
├──── handler.php (script for posting, deleting, like / dislike, spam reporting)
├──── load.php (script for loading comments)
├──── mail.php (script for sending mails to author or active comment members)

jComment script also have some files located in other directories including.

root/
├── include/bll/commentsmgt.php (data access & business layer for comment data processing)
├── include/bll/abusemgt.php (for spam / abuse data processing)
├── include/bll/dictionarymgt.php (for screening bad or voilated words)
├── include/bll/userratingsmgt.php (for user rating, like, dislike data processing)
├── sdk/ (comment demonstration script with practical examples)
├── include/entity/comments.php (comments data entity)
├── include/utility/utility.php (utility functions for date, link and other processings)
├── include/settings/general.php (for general configurations)

Contents

Default folder where to store member photos and thumbs.

contents/
├── member/ (for storing member contents)

CSS

Jugnoon jComment Script uses core bootstrap 3.0 css and js files by default with some custom css. You can adjust custom css based with your own design requirements. <

Note: jComment uses font-awesome icons instead of glyphicons in core script.

css/
├── base/ (main theme)
│    ├── images/ (Base theme images)
│    ├── bootstrap-glyphicons.css
│    ├── bootstrap.min.css
│    ├── layout.css (website own style sheet)
├── fonts/ (glyphicons fonts)
├── fonts/font-awesome/css/font-awesome.css (font awesome)

Core css file with all comment related classes are located under.

jcomments/
├── css/ (jcomment css folder)
│    ├── default.css (default css styles)
│    ├── style01.css
│    ├── style02.css
│    ├── style03.css (dark style)

Installation


Dependencies

Feature Dependency
--- There is no dependencies required for using jComment script in your application.

Steps

Installation steps

Installation of jComment script is same as Jugnoon Membership Kit, click on Installation Guide for more detail.


Database


Tables

List of tables uses by jComment script to store tree structure, data and relationship information in database.

tables/
├── comments (for storing comments)
├── abusereports (for storing spam reports)
├── userratings (for storing user like, dislike etc ratings)

Plugins


List of third party plugins we used in membership kit. Most of plugins located in folder plugins. All plugins we used are available for free but still you must use & obey their own license terms & conditions before using it.

Name Detail
Twitter Bootstrap http://getbootstrap.com/
Html Purifier http://htmlpurifier.org/
PHP Mailer For sending mails. https://github.com/PHPMailer/PHPMailer

Configurations


Core Configurations

Look and feel of comments can be adjusted from css files located in jcomments/css directory. Hoever there are huge amount of settings available which can help you adjust comment output and behaviour according to your requirements. jComment core file is jcomments/comment.js file.


Sample Implamentation

jComment can be implemented through jQuery easily. See simple implementation example below.

// jComment Sample Usage
$(function () {
   $('#jugnooncmt').jComment({
      showAvator: true,
      width: 750,
      contentID: '<?= $contentId ?>',
      userName: '<?= $auth->userName ?>',
      avatorWith: 65,
      avatorUrl: 'http://example.com/images/sample.jpg',
      avatorPictureName: 'sample.jpg',
      thumbDirectoryPath: '<?= SITE_DOMAIN . 'contents/member/' ?>',
      avatorCss: 'img-responsive avator',
      isMemberDirectory: true,
      profileUrl: '<?= SITE_DOMAIN . 'user/index.php?usr={p}' ?>',
      tComments: 140,
      requiredMsg: "Please enter few words to post comment",
      rootUrl: 'http://www.bootstrapkits.com/jcomment/',
      enableEnter: true,
      pageSize: 10
   });
});

Complete Configuration Prameters & Detail.

Name Default Value Detail
showAvator true Display user avator along with comment.
avatorUrl # Complete avator url of logged in user or default avator if not logged in incase showAvator is enabled. e.g 'http://www.example.com/images/user.jpg'
avatorPictureName '' Only avator image name without url e.g 'user.jpg'
defaultAvator '' Complete avator url like avatorUrl but for default thumb. It will be use in case any user have no profile thumb exist.
avatorWidth 65 width of avator along with left side width.
contentID 0 Record id on which comment has been posted. e.g video id, or photo id etc
contentUrl # Content url on which comment has been posted. To be used for sending record data in mails
contentTitle "" Content title on which comment has been post. Just used for sending mail purpose.
contentType 0 Differentiate each type of contents on which comment to be posted. e.g if you want to implement comment posting for different types of contents like (videos, photos, blogs, static pages. then you need to assign contentType for each type of record. e.g
  • 1: Photos
  • 2: Videos
  • 3: Static Pages
userName "" Logged in userName or Identity.
tComments 0 Total comments posted on this record. For scalability store comment stats along with photo or video or any record same as storing views stats. and at time of loading just retrieve comments stats too. This will avoid unnecessary load while counting comments manually by script then loading comments. If you are using tComments then you must not enable autoCount property.
autoCount false Force comment script to count and then load comments if count is more than zero.
width 500 Width of comment box in px.
postRows 2 Default rows to be set for comment posting textarea.
placeHolder Share your thoughts Default placeholder for comment posting textarea.
headingCaption All Comments Default heading caption.
profileUrl # User profile url.
avatorCss img-responsive img-rounded Apply css on user avator.
avatorTooltip "" Apply alt attribute to user avator
postLabel Post Comment store global font color for node
postBtnCss btn btn-xs btn-primary Apply css on post button
postBtnCaption Post Apply caption on post button.
loginMsg Sign In to Post Comment Set required sign in message.
norecordMsg No records found Set message to appear if no records found.
requiredMsg Please enter comment Set message to appear if user try to post empty comment.
reviewMsg Your comment has been posted and need to be reivewed Set message to appear if user posted unapproved message. If autoApproved is false.
loaderMsg Loading... Display message with loader.
rootUrl # Set domain root Url.
dirPath jcomments If you renamed core folder name jcomments where all jcomment files located then you must set this path properly. Also in case you want to implement comments within child folders. You must set this as ../jcomments
loadHandler load.php File responsible for loading comments.
processHandler handler.php File responsible for posting comments, removing comments, like, dislike comments, abuse reporting on comments.
thumbDirectoryPath # Main path where user avator stores. e.g http://www.domain.com/contents/member/.
isMemberDirectory true If directory created for each member then set its true.
enableEnter true Enable posting comments through enter button.
enablePostBtn true Enable posting comments through post button.
autoApproved true Auto approved comments if it is set as true.
loaderFileName jcomments/img/loader.gif Path of loader file name.
paginationType 1 Set pagination type,
  • 1: normal pagination
  • 2: next, prev button
  • 3: loading more..
paginationLinks 10 Total number of pagination links to be displayed if paginationType: 1.
selectedPage 1 Selected page number.
pageSize 20 Set page size for displaying maximum no of comments on each page..
showReply true Enable reply option.
replyLevel 3 Restricted reply button to maximum of 3 levels e.g show reply on parent, child and sub child comments.
showDate true Display posted date, time
showUser true Display user link.
showLike true Enable like action.
showDislike true Enable dislike action.
showFlag true Enable flag action
likeStyle 1 Set like style
  • 1: Thumbs Up
  • 2: Text Like
csrfToken false Enable extra protection. Note if enabled you must uncomment csrf token validation script under jcomments/handler.php file.

Data Access Layer


Files

All data processing and busines logic processing handle by files located at include/bll/ folder.

include/bll/
├── commentsmgt.php (for handling jComment data access & business layer managment)
├── abusereports.php (for handling jComment abuse, spam report processing)
├── userratings.php (for handling jComment user like, dislike data processing)

Data Access Examples

jComment script uses advance PDO script for handling and processing data between database and website. We have extended PDO classes for making code as much easy as we can. Here is list of sample example code.

Add Operation

$db = new DB();
$lastinsertid = true;
$queryAnalysis = false;
$id = $db->Insert("[tablename]", $fields, $lastinsertid, $queryAnalysis); 
return $id;

[tablename] represent table name, while $fields represent array of fields with values e.g

$fields = array('field01' => 'value01', 'field02' => 'value02');

Update Operation

$db = new DB();
return $db->Update("[tablename]", $fields, $filters, $queryanalysis);

$filters represent sql where filter clause.

$filter = array('id' => '23', 'isenabled' => '1'); // goes to WHERE id = 23 AND isenabled = 1;

Delete Operation

$db = new DB();
$db->Delete("[tablename]", $filters);

Count Operation

$db = new DB();
return $db->Count("[tablename]", $filters);

Fetch Operation

$db = new DB();
return fetch_values($fields, $isadmin, $filters, $ismultiple = false, $queryonly=false);

$fields list of table fields to fetch e.g "username, firstname, lastname, email"
$isadmin true or false
$filters where clause array of values to filter records
$ismultiple true or false for fetching single or multiple records
$queryonly true or false for returning sql query for analysis purpose.


Screenshots


Sample screen shot of jcomment


PHP jComment Sample Screenshot
Default screenshot of jComment.
PHP jComment Dark Screenshot
Dark style screenshot of jComment.
PHP jComment Custom Screenshot
Custom Style screenshot of jcomment.
PHP jComment Without Avator Screenshot
Without Avator screenshot of jcomment.
PHP jComment load more pagination screenshot
Load more pagination screenshot of jcomment.

Newsletter

Enter your e-mail and subscribe to our newsletter in order to get email notifications of our product upgrades and new product release.

Follow Us