Привет, Гость!
Главная
Вход

Последняя активность

Форум / JohnCMS / моды, дизайн / Модули для JohnCMS 7.x.x
Поиск
  need help in completing modul
jimy jimy [Off] [#] (29.05.2017 / 18:54)
Добавлено: 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
  1. $arg = [
  2. 'comments_table' => 'cms_library_comments',
  3. // Table with comments
  4. 'object_table' => 'library_texts',
  5. // Table of commented objects
  6. 'script' => '?act=comments',
  7. // Script name (with call parameters)
  8. 'sub_id_name' => 'id',
  9. // Name of the object to be commented on
  10. 'sub_id' => $id,
  11. // The identifier of the object to be commented on
  12. 'owner' => $res_obj['uploader_id'],
  13. // The owner of the object (the ID of the user who can manage the items, if allowed below)
  14. 'owner_delete' => true,
  15. // Opportunity for owner to delete comment
  16. 'owner_reply' => true,
  17. // Possibility for owner to reply to comment
  18. 'owner_edit' => false,
  19. // Possibility for owner to edit comment
  20. 'title' => _t('Comments'),
  21. // Section name
  22. 'context_top' => $context_top,
  23. // Displayed at the top of the list
  24. ];
  25. $comm = new Johncms\Comments($arg);
  26.  
  27. if ($comm->added) {
  28. $db->exec("UPDATE `library_texts` SET `comm_count`=" . ($res_obj['comm_count'] > 0 ? ++$res_obj['comm_count'] : 1) . " WHERE `id`=" . $id);
  29. }


this is the story table and story coment table :
  1. DROP TABLE IF EXISTS `story`;
  2. CREATE TABLE `story` (
  3. `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  4. `time` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  5. `user_name` VARCHAR(25) NOT NULL DEFAULT '',
  6. `user_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  7. `name` TEXT NOT NULL,
  8. `text` TEXT NOT NULL,
  9. PRIMARY KEY (`id`)
  10. )
  11. ENGINE = MyISAM
  12. DEFAULT CHARSET = utf8mb4;
  13.  
  14. DROP TABLE IF EXISTS `story_com`;
  15. CREATE TABLE IF NOT EXISTS `story_com` (
  16. `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  17. `time` INT(11) NOT NULL DEFAULT '0',
  18. `user_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  19. `story_id` INT(50) UNSIGNED NOT NULL DEFAULT '0',
  20. `text` text NOT NULL,
  21. PRIMARY KEY (`id`)
  22. )
  23. ENGINE = MyISAM
  24. DEFAULT CHARSET = utf8mb4;


Добавлено: 29.05.2017 / 18:54
I dnt know how to edit this
  1. 'comments_table' => 'cms_library_comments',
  2. // Table with comments
  3. 'object_table' => 'library_texts',
  4. // Table of commented objects
  5. 'script' => '?act=comments',
  6. // Script name (with call parameters)
  7. 'sub_id_name' => 'id',
  8. // Name of the object to be commented on
  9. 'sub_id' => $id,
  10. // The identifier of the object to be commented on
  11. 'owner' => $res_obj['uploader_id'],
  12. // The owner of the object (the ID of the user who can manage the items, if allowed below)
  13. 'owner_delete' => true,
  14. // Opportunity for owner to delete comment
  15. 'owner_reply' => true,
  16. // Possibility for owner to reply to comment
  17. 'owner_edit' => false,
  18. // Possibility for owner to edit comment
  19. 'title' => _t('Comments'),
  20. // Section name
  21. 'context_top' => $context_top,
kantry kantry [Off] [#] (29.05.2017 / 19:51)
Something like this...
  1. // ALTER TABLE `story_com` CHANGE `story_id` `sub_id` INT( 50 ) UNSIGNED NOT NULL DEFAULT '0';
  2. ALTER TABLE `story_com` ADD `reply` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ;
  3. ALTER TABLE `story_com` ADD `attributes` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
  4. ALTER TABLE `story` ADD `comm_count` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';

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

Изм. kantry (29.05.2017 / 19:52) [2]
  Всего: 2

Фильтр по автору
Скачать тему

Форум

Новые вверху
Главная
0 / 31

JohnCMS 7.1.0

Яндекс.Метрика
© JohnCMS