Skip to content

Instantly share code, notes, and snippets.

@AgelxNash
Created October 18, 2012 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AgelxNash/3911864 to your computer and use it in GitHub Desktop.
Save AgelxNash/3911864 to your computer and use it in GitHub Desktop.
HtmlInLine plugin for MODX Revo
<?php
/**************************************/
/** HtmlInLine plugin for MODX Revo
*
* @version 1.2
* @author Borisov Evgeniy aka Agel Nash (agel-nash@xaker.ru)
* @date 20.07.2012
*
* @category plugin
* @internal @event OnWebPagePrerender
* @internal @properties &tvHtmlInLine=ID TV;integer;1
* @internal @modx_category HTML-code
*
*
*
* INSTALL
* 1) Создать новый шаблон который только будет выводить содержимое документа: [[*content]]
* 2) К шаблону привязать новый TV параметр:
* - Тип ввода: список (одиночный выбор).
* - Возможные варианты: Да==1||Нет==0
* - Значение по умолчанию: 1
* 3) Создать параметр к плагину с именем tvHtmlInLine
* - Значение параметра: id TV параметра
* - Тип ввода: Целое
*/
/*************************************/
if($modx->event->name=='OnWebPagePrerender'){
$flag=true;
if(isset($tvHtmlInLine) && (int)$tvHtmlInLine>0){
$id = $modx->resource->get('id');
$tvs = $modx->getObject('modTemplateVarResource',array('tmplvarid'=>(int)$tvHtmlInLine, 'contentid'=>$id));
if($tvs && 0==$tvs->get('value')){
$flag=false;
}
}
if($flag){
$html = &$modx->resource->_output;
$html = preg_replace('|\s+|', ' ', $html);
$html = str_replace('> <','><',$html);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment