10 Sep 2010 
Support Center » Knowledgebase » Integration
 Integration
Article Integration of Pro Add Comments to your web page should be easy. First, you need to include our script to your .php file. Place following code at the very top of your .php file:

-------[ code ]---------------------------------------
<?php
define('CS_COMMENTS_PATH', './comments/');
require_once CS_COMMENTS_PATH . 'engine.php';
?>
-------[ code ]---------------------------------------

Constant CS_COMMENTS_PATH should point to your comments/ folder (default: ./comments/). If your php files are in the root of the website you would use './comments/'. For a subfolder, you need to use '../comments/', and for each subfolder level you need to add additional '../' (e.g. for a file in two subfolders www.yoursite.com/folder/sub/file.php you would use '../../comments/').

This will define $comments variable in PHP, which will contain Pro Add Comments PHP object, so make sure you don't use $comments variable in your (3rd party) PHP code.

Afterwards, you need to embed CSS and JS files. Place following code just above your </head> tag:

-------[ code ]---------------------------------------
<?php
echo $comments->HTMLHeader();
?>
-------[ code ]---------------------------------------

And that's it. The script is included successfully. Now, you should call ListComments() function where you want comments to appear. This function accepts two parameters:

1) $id (string) (optional) - Id of the article being commented. Leave it as null to use path of current PHP page as ID. Prepend it with backslash (/) to make it link. Default: null
2) $order (string) (optional) - ASC or DESC. Use ASC to sort comments in ascending order, or DESC to sort them in descending order. Default: ASC

Example:

-------[ code ]---------------------------------------
<?php
$id = (isset($_GET['id'])) ? $_GET['id'] : null;
ListComments($id);
?>
-------[ code ]---------------------------------------

This will also define $comment variable in PHP, which will contain each comment/comment info, so make sure you don't use $comment variable in your (3rd party) PHP code.

The other function you need to call is CommentForm(). It accepts also two parameters:

1) $id (string) (optional) - Id of the article being commented. Leave it as null to use path of current PHP page as ID. Prepend it with backslash (/) to make it link. Default: null
2) $showinfo (boolean) (optional) - True or false, whether you want to inform user about allowed (X)HTML tags or not, respectively. Default: true

Example:

-------[ code ]---------------------------------------
<?php
CommentForm($id);
?>
-------[ code ]---------------------------------------

Note: Currently it is possible to have ONLY ONE comment box per page.


Article Details
Article ID: 4
Created On: 23 Oct 2009 3:28 PM

 This article was helpful  This article was not helpful

Posted By: Luis Cordero (paypal@creativefortress.com) On: 26 Nov 2009 1:28 AM
In Google Chrome, there is an error. The content of your page will be aligned to the left. The easiest way to correct this is to edit style.css and take out the following lines:
* {
margin: 0px;
padding: 0px;
border: none;
}
 Back
 Log in  
Username:
Password:
Remember Me:
 
 Search
 Article Options
Home | Knowledgebase | Troubleshooter | News | Downloads
Language:

Helpdesk Software by Kayako SupportSuite v3.50.06