Submitted by: Amro   Date: 17-10-12 22:28

Seditio's core comments/ratings system is very easy to implement into your plugin. It takes a few lines of code and five steps as follows:

Step 1:

Pulls the switch (if the ratings/comments is on) from the url.

$ratings = sed_import('ratings','G','BOL',1,TRUE);
$comments = sed_import('comments','G','BOL',1,TRUE);

Step 2:

This is how your ratings/comments will be identified in the database, pretty self explainatory.

$item_code = 'name'.$id;

For Seditio's page system is uses..

$item_code = 'p'.$id;

Note: The default length of this column in Seditio is varchar(16) in MySQL. Normally any ID in Seditio is a maximum of int(11). So it is best to use identifiers at a maximum length of 5. Also be sure to not overlap identifiers with any other plugin/core.

Step 3:

Identify the URL of where this rating appears, this is done so that when you click the comment/rating icon it expands so the user can vote if he/she hasn't done so already.


$item_url = "plug.php?e=plugin&...".$id;

Step 4:

Retrieve/combine the variables for the final result.

list($comments_link, $comments_display, $comments_count) = sed_build_comments($item_code, $item_url, $comments);
list($ratings_link, $ratings_display) = sed_build_ratings($item_code, $item_url, $ratings);

Step 5:

Outputting the results can be done using any of the following ways..

"COMMENTS" => $comments_link,
"COMMENTS_DISPLAY" => $comments_display,
"COMMENTS_COUNT" => $comments_count,
"RATINGS" => $ratings_link,
"RATINGS_DISPLAY" => $ratings_display

Or by simply using {PHP.comments_link}, and so on, in your .tpl files.

Comments: (0)

No comments yet