I need some help in creating comment on modul story that I worked on now,
this is the code to call function comment
$arg = [
'comments_table' => 'cms_library_comments',
// Table with comments
'object_table' => 'library_texts',
// Table of commented objects
'script' => '?act=comments',
// Script name (with call parameters)
'sub_id_name' => 'id',
// Name of the object to be commented on
'sub_id' => $id,
// The identifier of the object to be commented on
'owner' => $res_obj['uploader_id'],
// The owner of the object (the ID of the user who can manage the items, if allowed below)
'owner_delete' => true,
// Opportunity for owner to delete comment
'owner_reply' => true,
// Possibility for owner to reply to comment
'owner_edit' => false,
// Possibility for owner to edit comment
'title' => _t('Comments'),
// Section name
'context_top' => $context_top,
// Displayed at the top of the list
];
$comm = new Johncms\Comments($arg);
if ($comm->added) {
$db->exec("UPDATE `library_texts` SET `comm_count`=" . ($res_obj['comm_count'] > 0 ? ++$res_obj['comm_count'] : 1) . " WHERE `id`=" . $id);
}
this is the story table and story coment table :
DROP TABLE IF EXISTS `story`;
CREATE TABLE `story` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`time` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`user_name` VARCHAR(25) NOT NULL DEFAULT '',
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`name` TEXT NOT NULL,
`text` TEXT NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = MyISAM
DEFAULT CHARSET = utf8mb4;
DROP TABLE IF EXISTS `story_com`;
CREATE TABLE IF NOT EXISTS `story_com` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`time` int(11) NOT NULL DEFAULT '0',
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`story_id` int(50) unsigned NOT NULL DEFAULT '0',
`text` text NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = MyISAM
DEFAULT CHARSET = utf8mb4;
Добавлено: 29.05.2017 / 18:54
I dnt know how to edit this
'comments_table' => 'cms_library_comments',
// Table with comments
'object_table' => 'library_texts',
// Table of commented objects
'script' => '?act=comments',
// Script name (with call parameters)
'sub_id_name' => 'id',
// Name of the object to be commented on
'sub_id' => $id,
// The identifier of the object to be commented on
'owner' => $res_obj['uploader_id'],
// The owner of the object (the ID of the user who can manage the items, if allowed below)
'owner_delete' => true,
// Opportunity for owner to delete comment
'owner_reply' => true,
// Possibility for owner to reply to comment
'owner_edit' => false,
// Possibility for owner to edit comment
'title' => _t('Comments'),
// Section name
'context_top' => $context_top,