tobiasolssonse
9/26/2017 - 9:21 AM

moretag Filter

$twig->addFilter('moretag', new Twig_Filter_Function('my_moretag'));

function my_moretag($text) {
			/*
			filter out text before <!--more--> tag, if no tag exist limit letters.
			*/
			if (strpos($text,'<!--more-->') !== false) {
	    	$text = current(explode("<!--more-->", $text));
			}else{
				// $pos	=		strpos($text, ' ', 60);
				$text =		substr($text,0,60 );
				$text = $text.' ...';
			}
	    	return $text;
	}