Last active
June 9, 2021 09:11
-
-
Save ExileofAranei/d62292ddd3c4a5558fe2141de48a5ac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
switch ($modx->event->name) { | |
case 'OnDocFormPrerender': | |
if (!$modx->controller->resourceArray) { | |
return; | |
} | |
// Array of TV ids to replace | |
$tvIDs = [108]; | |
$mimeType = $modx->getObject('modContentType', $modx->controller->resourceArray['content_type'])->get('mime_type'); | |
if ($mimeType == 'text/html' && $modx->getOption('pdotools_fenom_parser')) { | |
$mimeType = 'text/x-smarty'; | |
} | |
$modxTags = 1; | |
$aceHeight = $modx->getOption('ace.height'); | |
$script = ''; | |
foreach($tvIDs as $tvId) { | |
$extQuery = '#tv' . $tvId; | |
// Set default Ace height | |
$script .= "var tmpQueryAceReplace = Ext.query('$extQuery'); if (tmpQueryAceReplace.length > 0) { tmpQueryAceReplace[0].style.height = '" . $aceHeight . 'px' . "'; }"; | |
// Apply Ace to field | |
$script .= "MODx.ux.Ace.replaceTextAreas(Ext.query('$extQuery'), '$mimeType', $modxTags);"; | |
} | |
$modx->controller->addHtml('<script>Ext.onReady(function() {' . $script . '});</script>'); | |
break; | |
default: | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Инициализация текстового редактора для ТВ-полей при выключенной настройке "Использовать текстовый редактор"