Created
October 18, 2012 13:38
-
-
Save AgelxNash/3911864 to your computer and use it in GitHub Desktop.
HtmlInLine plugin for MODX Revo
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 | |
/**************************************/ | |
/** 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