Created
December 19, 2017 07:04
-
-
Save Sentinel-7/47e4a2351102f86d7d967880e18cd96a to your computer and use it in GitHub Desktop.
AceTv plugin для подсветки кода
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
//там ещё RTE подключается для определенные категорий ресуров) | |
//создаем плагин AceTv, событие на «OnDocFormRender» с кодом: | |
$script = ''; | |
$resource = ($resource instanceof modResource) | |
? | |
$modx->getObject('modResource',$resource->get('id')) | |
: $modx->getObject('modResource',(int)$resource); | |
// ACE | |
// Настройка под определенный тв-параметр в шаблоне | |
$templates_enable = array( // [id-шаблона] => array('tv[id-тв]') | |
'3' => array('tv14'), | |
'4' => array('tv14') | |
); | |
if ( $resource instanceof modResource && array_key_exists($resource->get('template'), $templates_enable) ) { | |
$script .= 'if (MODx.ux.Ace.replaceTextAreas) {'; | |
foreach ($templates_enable[$resource->get('template')] as $tv) { | |
$script .= 'MODx.ux.Ace.replaceTextAreas(Ext.query("textarea#' . $tv . '"));'; | |
} | |
$script .= '}'; | |
} | |
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function(){' . $script . '})</script>'); | |
//id шаблонов и тв-параметров находятся в скобках в дереве элементов. |
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
$resource = ($resource instanceof modResource) | |
? | |
$modx->getObject('modResource',$resource->get('id')) | |
: $modx->getObject('modResource',(int)$resource); | |
if ( $resource instanceof modResource ) { | |
$modx->regClientStartupHTMLBlock(' | |
<script> | |
Ext.onReady(function(){ | |
if (MODx.ux.Ace.replaceTextAreas) { | |
MODx.ux.Ace.replaceTextAreas(Ext.query(".x-form-textarea")); | |
} | |
}) | |
</script> | |
'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment