Open Jimmi08 opened 3 years ago
@Jimmi08 I believe this needs to be updated to v2.x standards, however, in the meantime, you might want to try using this setup, which comes from the links_page plugin:
//This is set to the table name you have decided to use.
$e_comment['eplug_comment_ids'] = "links_page";
//This is set to the location you'd like the user to return to after replying to a comment.
//$e_comment['reply_location'] = e_PLUGIN."links_page/links.php?comment.{NID}";
$e_comment['reply_location'] = e_HTTP.'links_page/links/comment/{NID}';
//A name for your plugin. It will be used in links to comments, in list_new/new.php.
$e_comment['plugin_name'] = "links_page";
//The path of the plugin folder
$e_comment['plugin_path'] = "links_page";
//This is the name of the field in your plugin's db table that corresponds to it's name or title.
$e_comment['db_title'] = "link_name";
//This is the name of the field in your plugin's db table that correspond to it's unique id number.
$e_comment['db_id'] = "link_id";
//qry must be set with a select_gen query.
//the main reason would be to check if a category from another table has a class restriction
//the id of the item should be provided as {NID}
//returned fields should at least contain the 'link_id' and 'db_id' fields set above
$e_comment['qry'] = "
SELECT l.*,c.*
FROM #links_page as l
LEFT JOIN #links_page_cat AS c ON l.link_category = c.link_category_id
WHERE l.link_id='{NID}' AND l.link_class REGEXP '".e_CLASS_REGEXP."' AND c.link_category_class REGEXP '".e_CLASS_REGEXP."' ";
@CaMer0n there are 2 different things:
Important:
$data = e107::getRegistry('e_comment'); returns NULL but test is against FALSE. Without this fix, comments are not displayed at all.
Can you fix this, please?
Not important now. Your example will not work. I tested it, compared both versions, checked if you didn't miss some code from links page plugin.
There is "callback" for that really old version and $e_comment is created correctly, $data are correct and comments are displayed. But after changing e_comment to your example it didn't work. I wanted to be sure that I didn't do mistake: $data with that really old way:
Array
(
[userjourna] => Array
(
[eplug_comment_ids] => userjourna
[plugin_name] => Denník
[plugin_path] =>
[reply_location] => /e107_plugins/userjournals/userjournals.php?blog.{NID}
[db_title] => userjournals_subject
[db_id] => userjournals_id
[db_table] => userjournals
[qry] =>
)
)
$data with your old way:
Array
(
[userjourna] => Array
(
[eplug_comment_ids] => userjourna
[reply_location] => /e107_plugins/userjournals/userjournals.php?blog.{NID}
[plugin_name] => Denník
[plugin_path] => userjournals
[db_title] => userjournals_subject
[db_id] => userjournals_id
[qry] =>
)
)
The working version needs [db_table] key and this is missing from your example. Just be aware of this, if you plan to update this.
Nowadays e_comment.php is not needed for adding comment system to any table
Example:
$plugin = 'candidate';
$id = $result['id'];
$subject = $result['id'].': '.$result['candidate_name'];
$rate = false;
$prevStyle = e107::getRender()->getStyle();
e107::getRender()->setStyle('nocaption');
$content .= e107::getComment()->render($plugin, $id, $subject, $rate);
e107::getRender()->setStyle($prevStyle);
You still need e_comment.php for the custom plugin, so this should be fixed.
If you want to display user comments, there is $e_comment
still used.
$data = $cobj->getCommentData(10, $from, 'comment_author_id ='.$id);
default:
if (isset($e_comment[$row['comment_type']]) && is_array($e_comment[$row['comment_type']]))
{
$var = $e_comment[$row['comment_type']];
....
Bug Description
with e_comment addon you can override e107 core comment system
The e_comment addon is not deprecated, but used to override the default comments 'engine' (e107). Check the social plugin for an example, where a Facebook comment engine is added.
But if your plugin use the core comment system, you still need to use e_comment for displaying your comments in the menu.
Problem is that this test fails in comment handler:
This
$data = e107::getRegistry('e_comment');
returns NULLand then this returns NULL too:
e_comment.php is set this way:
After removing that test of the new e_comment class, the menu works correctly and displays all needed comments.
PHP 7.2