Created
January 31, 2018 07:33
-
-
Save leotop/f8987dab4119b8210545951995ba1ff4 to your computer and use it in GitHub Desktop.
Плагин MODX Revo. Событие OnWebPagePrerender. Конструкция {% verbatim %}{% endverbatim %}. для отмены обработки любых тегов, синтаксис django
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
Обычный вызов чанка [[!code]]<hr> | |
{% verbatim %}Имитация вызова чанка [[!code]] | |
{% endverbatim %} | |
{% verbatim %}Имитация 2 вызова чанка [[!code2]] | |
{% endverbatim %} |
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 | |
// Конструкция {% verbatim %}{% endverbatim %} | |
// для отмены обработки тегов, синтаксис django | |
// Получаем оригинальное содержание из базы данных, без обработки | |
$res_content = $modx->resource->get('content'); | |
// Задаем тег отключающий обработку | |
$res_regular = "#\{\% verbatim \%\}(.*?)\{\% endverbatim \%\}#s"; | |
// Выбираем все соответствия регулярным выражением | |
// данные будут содержаться в $matches[1] | |
preg_match_all( | |
$res_regular, | |
$res_content, | |
$matches, | |
PREG_PATTERN_ORDER | |
); | |
// Получаем обработанный контент, для следующей замены тегов. | |
// Контент меняется по ссылке & | |
$output = &$modx->resource->_output; | |
// Производим замену в цикле по одному | |
foreach ($matches[1] as $value) { | |
$output = preg_replace($res_regular, $value, $output, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment