need help in completing modul

329
.
Добавлено: 29.05.2017 / 18:50
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,
.
kantry
Hey guys! Finally I'm gonna change status!?
Something like this...
// ALTER TABLE `story_com` CHANGE `story_id` `sub_id` INT( 50 ) UNSIGNED NOT NULL DEFAULT '0';
 ALTER TABLE `story_com` ADD `reply` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ;
ALTER TABLE `story_com` ADD `attributes` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `story` ADD `comm_count` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';

$arg = [
       'comments_table' => 'story_com',
       // Таблица с комментариями
       'object_table' => 'story',
       // Таблица комментируемых объек
       'script' => '?act=comments',
       // Имя скрипта (с параметрами выз
       'sub_id_name' => 'id',
....
Всего: 2