Skip to content

Instantly share code, notes, and snippets.

@Adoonq
Last active February 10, 2021 11:27
Show Gist options
  • Save Adoonq/ee0da87f7560f40c82659292236ee25e to your computer and use it in GitHub Desktop.
Save Adoonq/ee0da87f7560f40c82659292236ee25e to your computer and use it in GitHub Desktop.
Кастомные поля для комментариев (Tickets Modx)
/* Плагин с событием на OnBeforeCommentSave
https://modx.pro/help/4370
https://bezumkin.ru/sections/522/1540/ */
if ($modx->event->name == 'OnBeforeCommentSave') {
if(!empty($_POST['my_property_prop'])){
$properties = array(
'my_property' => $modx->stripTags($_POST['my_property_prop'])
);
} else {
$properties = array(
'my_property' => $modx->stripTags($_POST['my_property'])
);
}
$modx->event->params['TicketComment']->set('properties', $properties);
}
/* core/components/tickets/processors/mgr/comment/get.class.php
Костыль для функции cleanup() */
if (isset($comment['properties'])) {
foreach($comment['properties'] as $comment_key => $comment_value) {
$comment[$comment_key."_prop"] = $comment_value;
}
}
/* assets/components/tickets/js/mgr/comment/comment.window.js
Добавление нового поля в getFields */
{
xtype: 'textarea',
fieldLabel: _('comment'),
name: 'my_property_prop',
}
/* Вывод в чанке */
[[+properties.gender]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment