Created
February 11, 2013 21:37
-
-
Save govza/4757842 to your computer and use it in GitHub Desktop.
Modx Revo plugin, strip content and set it to introtext
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 | |
//OnBeforeDocFormSave | |
$introlength = $modx->getOption('IntrotextOptions',$scriptProperties,'400'); | |
$introtext= $resource ->introtext; | |
$text =$modx->stripTags($resource->content); | |
if(empty($introtext)){ | |
if (strlen($text) > $introlength) { | |
$cuttext = mb_substr($text, 0, $introlength,"UTF-8"); | |
$pos = mb_strrpos($cuttext, ' ',"UTF-8"); | |
$output = mb_substr($cuttext, 0, $pos,"UTF-8"); | |
} | |
else{ | |
$output = $text; | |
} | |
$resource->set('introtext',$output); | |
} | |
$resource->save(); | |
//$modx->event->output('внимание: '.$pos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment