TABLE OF CONTENTS
DOWNLOAD & INSTALLATION
First, the download links for the module, and also “installation instructions”.
LICENSE & DOWNLOAD
Core Boxx is released under the MIT License. You are free to use it for personal and commercial projects, and modify it as you see fit. On the condition that the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.
Download Core Boxx Reactions Module | GitHub | Source Forge
INSTALLATION & REQUIREMENTS
- Install the “main” Core Boxx and the user’s module first, then unzip this module into your existing Core Boxx project folder.
- Unzip this module into your existing Core Boxx project folder.
- Import
lib/SQL-Reacts.sql
into your database.
FILES LIST
LIBRARIES
lib/LIB-Reacts.php
The reactions library.lib/SQL-Reacts.php
Reactions database.
API
lib/API-Reacts.php
The reactions API endpoint.
ASSETS & PAGES
pages/PAGE-reacts.php
Demo page.assets/lidi.js
Simple like/dislike “widget” Javascript.assets/lidi.css
Simple like/dislike “widget” CSS.assets/lidi.png
Thumbs up and thumbs down image.assets/PAGE-reacts.js
Demo page Javascript.
DEVELOPMENT NOTES
It is possible to open the system up for “public reactions”, without the need for user registration.
- Change the
uid
to aVARCHAR
. - Then, generate a random string in the cookie as the “temporary
uid
“.
But of course, this is not the safest method – This is very susceptible to spam.
DATABASE REFERENCE
There is only one table to store the “likes/dislikes”. Feel free to add more fields as required.
REACTIONS TABLE
Field | Description |
id |
Primary key. The ID of the post/product/image/video – Whatever you want to add reactions to. |
user_id |
The user who made the reaction. |
reaction |
This is “preset” to -1 for dislike, 1 for like. |
P.S. Feel free to modify it to your own needs. For examples:
id
is currentlyBIGINT
. Change this toVARCHAR
, if you are using something like “SKU” for products.reaction
is pretty much an open field. Come up with your own “reaction codes” –2
for annoyed,3
for angry,4
for rage.
LIBRARY REFERENCE
Lastly, the list of library functions and API endpoints.
REACTIONS LIBRARY FUNCTIONS
Get the reactions for the specified item.
$id
Integer, the product/post/video/image ID.
$reacts = $_CORE->Reacts->get(99);
/* $reacts = [
"react" => [
[-1 => NUMBER OF DISLIKES],
[1 => NUMBER OF LIKES]
],
"user" => -1 OR 1 OR NONE
] */
Save a reaction. The user must be signed in first.
$id
item ID.$reaction
User’s reaction –1
like,-1
dislike,0
none (delete).
echo $_CORE->Reacts->save(123, -1) // USER DISLIKE ITEM 123
? "OK" : $_CORE->error;
REACTIONS API FUNCTIONS
Get reactions for the specified item.
$_POST["id"]
– Int, post/product/video/image ID.
Save/update a reaction.
$_POST["id"]
– Int, post/product/video/image ID.$_POST["reaction"]
–1
like,-1
dislike,0
none (delete).