<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://fbb.just4test.de/extern.php?action=feed&amp;tid=939&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Informationen für CMS/made simple / [GELÖST] CGBlog (bzw News): output kürzen]]></title>
		<link>http://www.cmsmadesimple.de/forum/viewtopic.php?id=939</link>
		<description><![CDATA[Die aktuellsten Beiträge in [GELÖST] CGBlog (bzw News): output kürzen.]]></description>
		<lastBuildDate>Sat, 10 Nov 2012 19:59:24 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21937#p21937</link>
			<description><![CDATA[<p>Hier eine weiter modifizierte Version:</p><p>- Falls ein Link bereits mit &lt;a href maskiert ist, werden die Link-Tags entfernt<br />- Falls keine Tags im String sind, wurde bis anhin beim kürzen kein $addString oder $link ausgewiesen.</p><div class="codebox"><pre class="vscroll"><code>&lt;?php


/**
* Smarty plugin
* http://www.smarty.net/forums/viewtopic.php?t=533
-----------------------------------------------------
* File: modifier.truncate_better.php
* Type: modifier
* Name: truncate_better
* Version: 1.3
* Date: January 13th, 2010
* Modified: November 10th, 2012
* Purpose: Cut a string preserving any tag nesting and matching.
* Install: Drop into the plugin directory.
* Author: Original Javascript Code: Benjamin Lupu &lt;lupufr@aol.com&gt;
* Translation to PHP &amp; Smarty: Edward Dale &lt;scompt@scompt.com&gt;
* Modification to add a string: Sebastian Kuhlmann &lt;sebastiankuhlmann@web.de&gt;
* Modification to add user defined closing text before closing tag if tag matches specified elements and added read more link with variable text:
* Avi J Liebowitz avij.com
* Clean up by Brice Favre &lt;brice.favre@blogspirit.com&gt;
* Add Check for naked URL by Lukas Blatter &lt;lukas.blatter@blattertech.ch&gt;
* Add $addstring and $link if there&#039;s no tags in string by Lukas Blatter &lt;lukas.blatter@blattertech.ch&gt;
* Add to ToolBox by Lukas Blatter &lt;lukas.blatter@blattertech.ch&gt;
* Example Usage {$htmlString|html_substr:&lt;lengh&gt;:&lt;string_to_add&gt;:&lt;link&gt;:&lt;link_text&gt;}
* 
* @param string
* @param integer
* @param string
* @param string
* @param string
* @return string
*
-------------------------------------------------------------
*/

function smarty_modifier_truncate_better($string, $length = 80, $addstring = &#039;...&#039;, $link = &#039;&#039;, $link_text = &#039;&#039;) {
    // only execute if text is longer than desired length
    if (strlen($string) &gt; $length) {
        if( !empty( $string ) &amp;&amp; $length &gt; 0 ) {
        	
        	if ($link != &#039;&#039;) {
				// check for naked url
				$regexp = &quot;&lt;a\s[^&gt;]*href=(\&quot;??)([^\&quot; &gt;]*?)\\1[^&gt;]*&gt;(.*)&lt;\/a&gt;&quot;; 
				if(preg_match_all(&quot;/$regexp/siU&quot;, $link, $matches)) 
					$link = $matches[2][0];
			} 
        	
            $isText = true;
            $ret = &quot;&quot;;
            $i = 0;

            $lastSpacePosition = -1;

            $tagsArray = array();
            $currentTag = &quot;&quot;;

            $noTagLength = strlen(strip_tags($string));

            // Parser loop
            $string_length = strlen($string);
            for($j = 0 ; $j &lt; $string_length ; $j++) {

                $currentChar = substr( $string, $j, 1 );
                $ret .= $currentChar;

                // Lesser than event
                if( $currentChar == &quot;&lt;&quot;) $isText = false;

                // Character handler
                if( $isText ) {

                    // Memorize last space position
                    if( $currentChar == &quot; &quot; ) {
                        $lastSpacePosition = $j;
                    }
                    else {
                        $lastChar = $currentChar;
                    }

                    $i++;
                } else {
                    $currentTag .= $currentChar;
                }

                // Greater than event
                if( $currentChar == &quot;&gt;&quot; ) {
                    $isText = true;

                    // Opening tag handler
                    if( ( strpos( $currentTag, &quot;&lt;&quot; ) !== false) &amp;&amp;
                            ( strpos( $currentTag, &quot;/&gt;&quot; ) === false) &amp;&amp;
                            ( strpos( $currentTag, &quot;&lt;/&quot;) === false) ) {

                        // Tag has attribute(s)
                        if( strpos( $currentTag, &quot; &quot; ) !== false ) {
                            $currentTag = substr( $currentTag, 1, strpos( $currentTag, &quot; &quot; ) - 1 );
                        } else {
                            // Tag doesn&#039;t have attribute(s)
                            $currentTag = substr( $currentTag, 1, -1 );
                        }

                        array_push( $tagsArray, $currentTag );

                    } else if( strpos( $currentTag, &quot;&lt;/&quot; ) !== false ) {
                        array_pop( $tagsArray );
                    }

                    $currentTag = &quot;&quot;;
                }

                if( $i &gt;= $length) {
                    break;
                }
            }

            // Cut HTML string at last space position
            if( $length &lt; $noTagLength ) {
                if( $lastSpacePosition != -1 ) {
                    $ret = substr( $string, 0, $lastSpacePosition );
                } else {
                    $ret = substr( $string, $j );
                }
            }

			// when there&#039;s no tags         
			if (count( $tagsArray ) == 0) {
				$ret .= $addstring;
				if (strlen($link))
					$ret .= &quot; &lt;a href=\&quot;&quot;. $link . &quot;\&quot; title=\&quot;&quot;. ($link_text != &#039;&#039; ? $link_text : $link) . &quot;\&quot;&gt;&quot; . ($link_text != &#039;&#039; ? $link_text : $link) . &quot;&lt;/a&gt;&quot;;
			}
			// there are tags
			else {
	            // Close broken XHTML elements   
	            while( count( $tagsArray ) != 0 ) {
	                if ( count( $tagsArray ) &gt; 1 ) {
	                    $aTag = array_pop( $tagsArray );
	                    $ret .= &quot;&lt;/&quot; . $aTag . &quot;&gt;\n&quot;;
	                }
	                // You may add more tags here to put the link and added text before the closing tag
	                elseif ($aTag = &#039;p&#039; || &#039;div&#039;) {
	                    $aTag = array_pop( $tagsArray );
	                    $ret .= $addstring;
	                    if (strlen($link))
	                    	$ret .= &quot; &lt;a href=\&quot;&quot;. $link . &quot;\&quot; title=\&quot;&quot;. ($link_text != &#039;&#039; ? $link_text : $link) . &quot;\&quot;&gt;&quot; . ($link_text != &#039;&#039; ? $link_text : $link) . &quot;&lt;/a&gt;&lt;/&quot; . $aTag . &quot;&gt;\n&quot;;
	                }
	                else {
	                    $aTag = array_pop( $tagsArray );
	                    $ret .= &quot;&lt;/&quot; . $aTag . &quot;&gt;&quot; . $addstring;
	                    if (strlen($link))
	                    	$ret .= &quot; &lt;a href=\&quot;&quot;. $link . &quot;\&quot; title=\&quot;&quot;. ($link_text != &#039;&#039; ? $link_text : $link) . &quot;\&quot;&gt;&quot; . ($link_text != &#039;&#039; ? $link_text : $link) . &quot;&lt;/a&gt;\n&quot;;
	                }
	            }
			}
        } 
        else {
            $ret = &quot;&quot;;
        }

        return $ret;
    }
    else {
        return $string;
    }
} </code></pre></div><p>Der Modifier wird in der nächsten ToolBox Version als tbTruncateBetter eingebunden sein.</p>]]></description>
			<author><![CDATA[dummy@example.com (nockenfell)]]></author>
			<pubDate>Sat, 10 Nov 2012 19:59:24 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21937#p21937</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21931#p21931</link>
			<description><![CDATA[<p>Thx!</p>]]></description>
			<author><![CDATA[dummy@example.com (cyberman)]]></author>
			<pubDate>Sat, 10 Nov 2012 18:23:01 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21931#p21931</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21911#p21911</link>
			<description><![CDATA[<p>Link hat sich geändert. Ist jetzt <a href="http://tinyurl.com/d9c2oe3" rel="nofollow">hier</a> zu finden.</p>]]></description>
			<author><![CDATA[dummy@example.com (NaN)]]></author>
			<pubDate>Fri, 09 Nov 2012 08:39:23 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21911#p21911</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21906#p21906</link>
			<description><![CDATA[<div class="quotebox"><cite>NaN schrieb:</cite><blockquote><div><p>Habe daraus mal einen Smarty-Modifikator für CMSms gemacht: <a href="http://dl.dropbox.com/u/2876578/CMSms/Misc/modifier.truncate_better.php" rel="nofollow">http://dl.dropbox.com/u/2876578/CMSms/M … better.php</a></p></div></blockquote></div><p>Bekomme hier nur &#039;ne 404er Meldung ... ist das so gewollt?</p>]]></description>
			<author><![CDATA[dummy@example.com (cyberman)]]></author>
			<pubDate>Thu, 08 Nov 2012 21:32:11 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21906#p21906</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21903#p21903</link>
			<description><![CDATA[<p>in der Datei function.truncate_better.php</p>]]></description>
			<author><![CDATA[dummy@example.com (nockenfell)]]></author>
			<pubDate>Thu, 08 Nov 2012 14:32:44 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21903#p21903</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21901#p21901</link>
			<description><![CDATA[<p>Wo steht denn diese Funktion?</p>]]></description>
			<author><![CDATA[dummy@example.com (ben04)]]></author>
			<pubDate>Thu, 08 Nov 2012 14:28:59 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21901#p21901</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21871#p21871</link>
			<description><![CDATA[<p>Du musst den Funktionsnamen ändern:</p><p>bisher smarty_cms_function_truncate_better</p><p>neu smarty_function_truncate_better</p>]]></description>
			<author><![CDATA[dummy@example.com (nockenfell)]]></author>
			<pubDate>Wed, 07 Nov 2012 12:41:19 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21871#p21871</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21870#p21870</link>
			<description><![CDATA[<p>Ich weiß der Thread ist schon etwas älter, aber ich bräuchte etwas Hilfe:</p><p>Ich hab das truncate-better.php in den /plugin Order geschoben, und wollte es jetzt über das {truncate_better} Tag einbinden, allerdings kennt CMSMS das Tag nicht. Muss ich noch irgendwas machen außer die .php in den /Plugin-Ordner zu schieben, damit das Tag erkannt wird?</p>]]></description>
			<author><![CDATA[dummy@example.com (ben04)]]></author>
			<pubDate>Wed, 07 Nov 2012 12:31:32 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=21870#p21870</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8605#p8605</link>
			<description><![CDATA[<p>fein!</p>]]></description>
			<author><![CDATA[dummy@example.com (nicmare)]]></author>
			<pubDate>Fri, 17 Jun 2011 11:41:06 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8605#p8605</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8604#p8604</link>
			<description><![CDATA[<p>Also ich hab da mit dem modifier keine Fehler feststellen können.<br />Vielleicht lag es ja an den kleinen Problemen, die ich da rausgenommen habe.<br />Folgender Demotext:</p><div class="quotebox"><blockquote><div><p>&lt;p&gt;The &lt;br /&gt;news&lt;/p&gt;<br />&lt;hr /&gt;<br />&lt;p&gt;module &lt;br /&gt;was &lt;br /&gt;installed.&lt;/p&gt;<br />&lt;hr /&gt;<br />&lt;p&gt;Exciting.&lt;/p&gt;<br />&lt;p&gt;This news article is not using the Summary field and therefore there is no link to read more.&lt;/p&gt;<br />&lt;hr /&gt;<br />&lt;p&gt;But you can click on the news heading to read only this article.&lt;/p&gt;<br />&lt;p&gt;Some Text here&lt;/p&gt;</p></div></blockquote></div><p>Und dann z.B. mit {$entry-&gt;content|truncate_better:&#039;19&#039;} gekürzt.<br />Ergebnis:</p><div class="quotebox"><blockquote><div><p>&lt;p&gt;The &lt;br /&gt;news&lt;/p&gt;<br />&lt;hr /&gt;<br />&lt;p&gt;module...&lt;/p&gt;</p></div></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (NaN)]]></author>
			<pubDate>Fri, 17 Jun 2011 11:28:35 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8604#p8604</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8599#p8599</link>
			<description><![CDATA[<p>Stimmt. Da war nochwas.<br />Was ich interessant finde, ist, dass der Code keinerlei reguläre Ausdrücke verwendet, sondern nur einfache string-Funktionen. Allerdings muss er dazu in einer For-Schleife jedes einzelne Zeichen durchgehen und überprüfen. Damit wäre der Geschwindigkeits-Vorteil gegenüber regulären Ausdrücken möglicherweise wieder hinfällig.<br />Mal schaun, was man da noch drehen kann.</p>]]></description>
			<author><![CDATA[dummy@example.com (NaN)]]></author>
			<pubDate>Fri, 17 Jun 2011 09:59:06 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8599#p8599</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8593#p8593</link>
			<description><![CDATA[<p>wenn ich mich recht erinnere, gibt es aber Probleme mit &lt;br/&gt; und &lt;hr/&gt; richtig? die werden einfach &quot;beschnitten&quot;.</p>]]></description>
			<author><![CDATA[dummy@example.com (nicmare)]]></author>
			<pubDate>Fri, 17 Jun 2011 07:53:14 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8593#p8593</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8588#p8588</link>
			<description><![CDATA[<p>Hab den Code eigentlich fast 1:1 kopiert und nur für einen Modifikator umgeschrieben.<br />Lediglich sowas wie if($aTag = &#039;p&#039; || &#039;div&#039;) hab ich korrigiert. (falscher syntax. richtig ist if($aTag == &#039;p&#039; || $aTag == &#039;div&#039;). Aber die Funktionsweis ist ansonsten identisch. Ist vielleicht auch einfach nur Gewöhnungsache. Der eine schreibt lieber {truncate_better ... } der andere liebe {...|truncate_better}.<br />Ich wollte nur kein UDT haben. Hätte auch ein normales Plugin draus machen können. Aber da truncate keins ist, dachte ich mir, mache ich aus truncate_better eben auch keins. Die Sache mit den Bildern ist damit nicht zu lösen. Das müsstest Du evtl. mit regex_replace machen.</p><p>Bsp.:</p><div class="codebox"><pre><code>{$entry-&gt;content|truncate_better:&#039;80&#039;|regex_replace:&#039;/&lt;img [^&gt;]*\/?&gt;/&#039;:&#039;&#039;}</code></pre></div><p>oder umgekehrt</p><div class="codebox"><pre><code>{$entry-&gt;content|regex_replace:&#039;/&lt;img [^&gt;]*\/?&gt;/&#039;:&#039;&#039;|truncate_better:&#039;80&#039;}</code></pre></div><p>dann werden Bilder aus dem Summary komplett entfernt.<br />Oder Du verwendest relative Breitenangaben fü die Bilder:</p><div class="codebox"><pre><code>&lt;img ... width=&quot;100%&quot; /&gt;</code></pre></div><p>Dann werden sie im Browser so skaliert, dass sie auch in die Sidebar passen.<br />Ist aber vielleicht auch nicht so schön.</p><p>Wenn Du wirklich nur reinen Text haben willst, dann hilft Dir vielleicht der <a href="http://www.smarty.net/docsv2/en/language.modifier.strip.tags.tpl" rel="nofollow">strip_tags</a> Modifikator. Dann kannst Du auch einfach nur truncate verwenden, um die Ausgabe zu begrenzen, weil ja dann keine HTML Tags mehr da sind, die durcheinandergeraten können.</p><p>Bsp.:</p><div class="codebox"><pre><code>{$entry-&gt;content|strip_tags:false|truncate:160}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (NaN)]]></author>
			<pubDate>Fri, 17 Jun 2011 00:50:02 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8588#p8588</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8587#p8587</link>
			<description><![CDATA[<p>Danke, konkrete Unterschiede hast Du da nicht?<br />Kuck mir das morgen mal an. Aber wüsste schon gern, welche Unterschiede konkret zu erwarten sind.</p>]]></description>
			<author><![CDATA[dummy@example.com (mike-r)]]></author>
			<pubDate>Fri, 17 Jun 2011 00:31:51 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8587#p8587</guid>
		</item>
		<item>
			<title><![CDATA[Re: [GELÖST] CGBlog (bzw News): output kürzen]]></title>
			<link>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8586#p8586</link>
			<description><![CDATA[<p>Nö, hat damit nix zu tun.<br />Der Modifikator ist zum einen um ein paar kleine Fehler reduziert worden und zum anderen ist er wie ein Plugin performanter als ein UDT.<br />Das ist schon alles.</p><p>Brauchte das Ding auch gerade und hatte keine Lust auf einen UDT. Und dabei sind mir ein paar Kleinigkeiten aufgefallen, die ich gleich behoben habe.</p>]]></description>
			<author><![CDATA[dummy@example.com (NaN)]]></author>
			<pubDate>Fri, 17 Jun 2011 00:15:23 +0000</pubDate>
			<guid>http://www.cmsmadesimple.de/forum/viewtopic.php?pid=8586#p8586</guid>
		</item>
	</channel>
</rss>
