by Jairon Landa
In this tutorial, I will show you how to integrate Disqus comment for your CodeIgniter 4 project. Basic web project is included to demonstrate the Disqus comment.
Note: Internet connection is required to run Disqus comment.
Github: https://github.com/Jaironlanda/CodeIgniter4-disqus
Create a Disqus account. (https://disqus.com/profile/signup/)
Register a forum for your website. https://disqus.com/admin/create/
Example:
Next, select a plan. In this tutorial, i'm using Basic plan.
Configure your Disqus. Select Settings at the admin navigation menu.
Enter appropriate detail about your website.
Example:
and Click Save
Select Installation menu
For platform, select I don’t see my platform listed, install manually with Universal Code.
Example:
Place the following code where Disqus to load.
Example:
PAGE_URL
Replace this with your URL blog. Example: 'http://example.com/id/12/my-blog-title/'
PAGE_IDENTIFIER
Page's unique identifier variable. For demonstration, I am using blog id. Example: '75'
This project I'm using CodeIgniter 4 + Bootstrap 4 and database MySQL. This is simple project to test Disqus comment for single blog post.
Project preview
MySQL structure
Query
CREATE TABLE `blog-disqus`.`blog` ( `blog_id`
INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(355) NOT NULL ,
`slug` VARCHAR(355) NOT NULL ,
`content` TEXT NOT NULL ,
`created_at` DATETIME NOT NULL ,
`updated_at` DATETIME NOT NULL ,
PRIMARY KEY (`blog_id`))
ENGINE = InnoDB;
Front-end
Blog Index Preview
View app\Views\blog_index.php
This view will load all blog data from database.
View app\Views\blog_view.php
Preview
As you can see, at line 42
I'm using current_url()
. This helper is automatically loaded by the framework on every request.
Back-end
app\Models\BlogModel.php
app\Controllers\Home.php
You learn how to integrate Disqus comments in CodeIgniter 4 framework.
Backend and Frontend developer, a.k.a full-stack developer.
Kg Bundung, Tuaran