Integration
Once the script installation is complete you will need to add the script to your page(s). To do this you will need at least one file to add the script to. You may already have this file existing somewhere on your site, perhaps it's an article that you have written or some other useful information. If you don't then you will need to create one now. Once you know which file to add the script to, move onto the steps below.
There are two types of integration that you can choose from - these are an iFrame integration and a PHP integration. Please read our iFrame vs PHP comparison to decide which is right for you.
iFrame Integration +
Tip: Make sure you have added your site in 'Manage -> Sites'.
In the package you downloaded, there is an example.html file which you can look at.
Step One
Add the following inside the HTML head tag of your file. Remember to replace your-domain.com with your own domain name (this should be the domain where you installed Commentics).
<script src="http://your-domain.com/comments/embed.js"></script>
Step Two
Add the following inside the HTML body tag of your file, wherever you want the comments to be shown.
<div id="commentics"></div>
Step Three
This step is optional. Add the following inside the HTML body tag of your file.
The identifier can contain any value. Just make sure that it's unique to each page that you add the script to. If missing, Commentics will use the URL of your page.
The reference should be a short descriptive term of the page. It is shown to your visitors. Using the heading of the page is typically a good idea. If missing, Commentics will use the HTML title tag of your page.
<script>
var commentics_config = {
'identifier': '1',
'reference' : 'Page One'
};
</script>
PHP Integration +
In the package you downloaded, there is an example.php file which you can look at.
Step One
The first step for integration is to add the following line to the very top of your file. It is necessary for session-dependant features to work. By first line, this means even above the <!DOCTYPE html> and <html> line. If you already have this then there is no need to add it again.
<?php session_start(); ?>
Step Two
Next you need to add the following two lines inside the HTML head tag of your file. The first line declares the UTF-8 charset which means that foreign characters can be displayed. If you have the 'ISO-8859-1' charset tag, or any other charset tag, please remove it and replace it with this UTF-8 one. The second line makes the page responsive so it can be viewed on mobiles and tablets. If you already have these lines then there is no need to add them again.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Step Three
The last part is the code to actually display the comments and the comment form. This should be added somewhere in your HTML body tag, wherever you want the comments to be shown.
The identifier can contain any value. Just make sure that it's unique to each page that you add the script to.
The reference should be a short descriptive term of the page. It is shown to your visitors. Using the heading of the page is typically a good idea.
The folder is the name of the /comments/ folder. You may have renamed this during installation. Make sure it starts and ends in a forward slash.
There is never any need to edit the last line.
<?php
$cmtx_identifier = '1';
$cmtx_reference = 'Page One';
$cmtx_folder = '/comments/';
require($_SERVER['DOCUMENT_ROOT'] . $cmtx_folder . 'frontend/index.php');
?>
Alternatively, if your website is built using a popular platform we may have an integration plugin for it.