<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Smarty &#8211; am Röschibach</title>
	<atom:link href="/tag/smarty/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description></description>
	<lastBuildDate>Wed, 28 Feb 2018 14:39:19 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0</generator>
	<item>
		<title>PhpStorm: Syntax-Highlighting für PHP Codeblöcke in Smarty</title>
		<link>/2012/11/phpstorm-syntax-highlighting-fur-php-codeblocke-in-smarty/</link>
		<comments>/2012/11/phpstorm-syntax-highlighting-fur-php-codeblocke-in-smarty/#respond</comments>
		<pubDate>Fri, 16 Nov 2012 13:08:56 +0000</pubDate>
		<dc:creator><![CDATA[jule_]]></dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">/?p=1880</guid>
		<description><![CDATA[Ein zugegebenermassen sehr spezielles Problem: In unserer Web-Applikation nach MVC Architektur übernimmt Smarty (Version 2.6.26) die Darstellung. Obwohl es nicht dem MVC-Konzept entspricht, übernimmt Smarty die Erstellung von Excel Reports via PHPExcel. Um in Smarty &#8222;native&#8220; PHP Code schreiben zu können, braucht man die {php}&#8230;{/php} Anweisungen. Und da diese Code-Blöcke unter Umständen sehr lange werden [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Ein zugegebenermassen sehr spezielles Problem:</p>
<p>In unserer <a title="externer Link: Crealogix CLX.Tracker" href="http://www.crealogix.com/produkte/education-produkte/ausbildungsplattformen/clxtracker/">Web-Applikation</a> nach <a title="externer Link: Model View Controller - Wikipedia" href="http://de.wikipedia.org/wiki/Model_View_Controller">MVC Architektur</a> übernimmt <a title="externer Link: Smarty Template Engine - Wikipedia" href="http://de.wikipedia.org/wiki/Smarty">Smarty</a> (Version 2.6.26) die Darstellung. Obwohl es nicht dem MVC-Konzept entspricht, übernimmt Smarty die Erstellung von Excel Reports via <a title="externer Link: PHPExcel" href="https://phpexcel.codeplex.com/">PHPExcel</a>. Um in Smarty &#8222;native&#8220; PHP Code schreiben zu können, braucht man die <span style="font-family: 'Courier New', Courier, monospace;">{php}&#8230;{/php}</span> Anweisungen. Und da diese Code-Blöcke unter Umständen sehr lange werden können wäre es praktisch wenn meine <a title="externer Link: Integrierte Entwicklungsumgebung - Wikipedia" href="http://de.wikipedia.org/wiki/Integrierte_Entwicklungsumgebung">IDE</a> <a title="externer Link: PhpStorm - Wikipedia" href="http://de.wikipedia.org/wiki/PHPStorm">PhpStorm</a> hier PHP Syntax-Highlighting anwenden würde.</p>
<p>Die perfekte Lösung &#8211; nämlich das Definieren von <span style="font-family: 'Courier New', Courier, monospace;">{php}&#8230;{/php}</span> als Auslöser für das Highlighten analog zu <span style="font-family: 'Courier New', Courier, monospace;">&lt;?php &#8230; ?&gt;</span> &#8211; habe ich leider nicht gefunden. Aber einen brauchbaren <a title="externer Link: Workaround - Wikipedia" href="https://de.wikipedia.org/wiki/Workaround">Workaround</a>:</p>
<p><span id="more-1880"></span></p>
<p style="text-align: center;"><a href="/wp-content/uploads/2012/11/no_syntaxhighlighting.jpg" rel="shadowbox[sbpost-1880];player=img;" title="Code ohne Syntaxhighlighting"><img class="aligncenter size-medium wp-image-1881 centerfloat" title="Code ohne Syntaxhighlighting" src="/wp-content/uploads/2012/11/no_syntaxhighlighting-300x130.jpg" alt="Code ohne Syntaxhighlighting" width="300" height="130" srcset="/wp-content/uploads/2012/11/no_syntaxhighlighting-300x130.jpg 300w, /wp-content/uploads/2012/11/no_syntaxhighlighting.jpg 920w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Bei uns haben alle Excel-Exports das Namensschema <em>exportX.inc.tpl</em>, wobei <em>X</em> eine Zahl ist. Das mache ich mir zu Nutze und erweitere in den Einstellungen (<span style="font-family: 'Courier New', Courier, monospace;">CTRL</span>+<span style="font-family: 'Courier New', Courier, monospace;">ALT</span>+<span style="font-family: 'Courier New', Courier, monospace;">S</span>) die registrierten Patterns für PHP Dateien:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2012/11/settings.jpg" rel="shadowbox[sbpost-1880];player=img;" title="PhpStorm 5.0.4 Einstellungsdialog"><img class="aligncenter size-medium wp-image-1885 centerfloat" title="PhpStorm 5.0.4 Einstellungsdialog" src="/wp-content/uploads/2012/11/settings-300x164.jpg" alt="PhpStorm 5.0.4 Einstellungsdialog" width="300" height="164" srcset="/wp-content/uploads/2012/11/settings-300x164.jpg 300w, /wp-content/uploads/2012/11/settings.jpg 972w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Die PHP Code-Blöcke werden allerdings immer noch nicht farbig hervorgehoben dargestellt. Dazu muss man einen kleinen Trick anwenden:</p>
<p style="text-align: center;"><a href="/wp-content/uploads/2012/11/with_syntaxhighlighting.jpg" rel="shadowbox[sbpost-1880];player=img;" title="Code ohne Syntaxhighlighting"><img class="aligncenter size-medium wp-image-1887 centerfloat" title="Code ohne Syntaxhighlighting" src="/wp-content/uploads/2012/11/with_syntaxhighlighting-300x130.jpg" alt="Code ohne Syntaxhighlighting" width="300" height="130" srcset="/wp-content/uploads/2012/11/with_syntaxhighlighting-300x130.jpg 300w, /wp-content/uploads/2012/11/with_syntaxhighlighting.jpg 920w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Die <span style="font-family: 'Courier New', Courier, monospace;">{*&lt;?php*}</span> Anweisung in der ersten Zeile &#8222;verwirrt&#8220; den PhpStorm Syntax-Highlighter und sorgt dafür, dass PHP Code in der ganzen Datei (!) hervorgehoben dargestellt wird. Die Smarty Template Engine stört sich nicht an dem <a title="externer Link: Tag - Wikipedia" href="http://de.wikipedia.org/wiki/Tag_%28Informatik%29">Tag</a>, weil in Smarty Block-Kommentare mit <span style="font-family: 'Courier New', Courier, monospace;">{*</span> und <span style="font-family: 'Courier New', Courier, monospace;">*}</span> definiert werden.</p>
<p>Wie gesagt, das Problem ist sehr speziell und der Workaround hat auch seine Nachteile (siehe rot unterwellte Bereiche im Screenshot), aber für meine Zwecke perfekt.</p>
]]></content:encoded>
			<wfw:commentRss>/2012/11/phpstorm-syntax-highlighting-fur-php-codeblocke-in-smarty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty Plugin in einem anderen Smarty Plugin aufrufen</title>
		<link>/2011/06/smarty-plugin-in-einem-anderen-smarty-plugin-aufrufen/</link>
		<comments>/2011/06/smarty-plugin-in-einem-anderen-smarty-plugin-aufrufen/#respond</comments>
		<pubDate>Wed, 22 Jun 2011 12:36:39 +0000</pubDate>
		<dc:creator><![CDATA[jule_]]></dc:creator>
				<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Smarty]]></category>

		<guid isPermaLink="false">/?p=412</guid>
		<description><![CDATA[Heute stand ich vor dem relativ trivialen Problem, dass ich die Funktionalität eines Smarty Plugins in einem anderen Smarty Plugin verwenden wollte. Konkret ging es darum ein Plugin zum dynamischen Konstruieren von Dateinamen in einem Plugin zur Darstellung einer Tabellenzeile aufzurufen. Google hat mir bei der Lösung vorerst nicht wirklich geholfen, erst durch Variation des [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Heute stand ich vor dem relativ trivialen Problem, dass ich die Funktionalität eines <a title="externer Link: Smarty PHP Template Engine" href="http://www.smarty.net/">Smarty</a> Plugins in einem anderen Smarty Plugin verwenden wollte. Konkret ging es darum ein Plugin zum dynamischen Konstruieren von Dateinamen in einem Plugin zur Darstellung einer Tabellenzeile aufzurufen.</p>
<p><span id="more-412"></span></p>
<p>
Google hat mir bei der Lösung vorerst nicht wirklich geholfen, erst durch Variation des Suchterms stiess ich schliesslich auf <a title="externer Link: Velvet Blues - Smarty Templates: How To Create Custom Functions" href="http://www.velvetblues.com/web-development-blog/smarty-templates-create-custom-functions/">diesen Beitrag</a>, bei dem in den Kommentaren die Lösung zu finden war:</p>
<pre><pre class="brush: php; tab-size: 4; title: function.load_file.php; notranslate">
function smarty_function_load_file($params, &amp;$smarty) {
    if (empty($params['file'])) {
        $smarty-&gt;trigger_error(&quot;assign: missing 'file' parameter&quot;);
        return;
    }
    else {
        $file = $params['file'];
    }

    // assemble output path here
    // ...

    return $outputPath;
}
</pre>
<p>
Normalerweise wird das load_file plugin im Smarty Template mit folgender Zeile aufgerufen:
</p>
<pre><pre class="brush: xml; tab-size: 4; title: index.inc.tpl; notranslate">
&lt;img src=&quot;{load_file file='path/to/my/file.gif'}&quot; /&gt;
</pre>
<p>
Das folgende Codeschnipsel verwendet die load_file Funktion innerhalb eines anderen Smarty Plugins:
</p>
<pre><pre class="brush: php; highlight: [4,8]; title: function.html_table_row.php; notranslate">
function smarty_function_html_table_row($params, &amp;$smarty) {

    // include the smarty load file plugin
    require_once($smarty-&gt;_get_plugin_filepath('function', 'load_file'));

    // some code skipped

    $returnValue .= '&lt;img src=&quot;' . smarty_function_load_file(array('file' =&gt; 'path/to/my/file.gif'), $smarty) . '&quot; /&gt;';

    // even more skipped code

    return $returnValue;
}
</pre>
<p>
Die Magie passiert in Zeile 4, wo das function.load_file.php Plugin geladen wird, und in Zeile 8, in der die Funktion dann aufgerufen wird. Die Parameter werden in Form eines assoziativen Arrays als erster Parameter übergeben. In meinem Fall übergebe ich &#8218;file&#8216;. Parameter zwei ist das Smarty Objekt, das scheinbar zwingend benötigt wird.</p>
]]></content:encoded>
			<wfw:commentRss>/2011/06/smarty-plugin-in-einem-anderen-smarty-plugin-aufrufen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
