<?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>hihn.org &#187; smarty</title>
	<atom:link href="http://hihn.org/tag/smarty/feed/" rel="self" type="application/rss+xml" />
	<link>http://hihn.org</link>
	<description></description>
	<lastBuildDate>Mon, 05 Mar 2012 19:04:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>International programmieren mit Zend_Translate</title>
		<link>http://hihn.org/2009/02/international-programmieren-mit-zend_translate/</link>
		<comments>http://hihn.org/2009/02/international-programmieren-mit-zend_translate/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 15:49:45 +0000</pubDate>
		<dc:creator>rh</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">https://hihn.org/?p=316</guid>
		<description><![CDATA[Mit dem im Zend Framework enthaltenen Zend Translate kann man komfortabel international programmieren. Beispiel mit Zend_Translate_Adapter_Array: In der de.php werden die deutschen Sprachvariablen gespeichert. /** * de.php */ return array( 'message1' => 'das ist die erste Nachricht' ); In der en.php die englischen usw. /** * en.php */ return array( 'message1' => 'this is the [...]]]></description>
			<content:encoded><![CDATA[<p>Mit dem im <a href="http://framework.zend.com/">Zend Framework</a> enthaltenen <a href="http://framework.zend.com/manual/en/zend.translate.html">Zend Translate</a> kann man komfortabel international programmieren.</p>
<p>Beispiel mit Zend_Translate_Adapter_Array:</p>
<p>In der de.php werden die deutschen Sprachvariablen gespeichert.</p>
<pre>
/**
 * de.php
 */
return array(
    'message1' => 'das ist die erste Nachricht'
);
</pre>
<p>In der en.php die englischen usw.</p>
<pre>
/**
 * en.php
 */
return array(
    'message1' => 'this is the first message'
);
</pre>
<p>Initialisierung und Ausgabe:</p>
<pre>
/**
 * index.php
 */
$translate= new Zend_Translate('array', './lang/en.php', 'en');
echo $translate->_("message1");
</pre>
<p>Benutzung mit smarty:</p>
<pre>
$var = $translate->_("message1");
$s->assign("var", $var);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hihn.org/2009/02/international-programmieren-mit-zend_translate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datensätze in einem Smarty-Template ausgeben</title>
		<link>http://hihn.org/2007/12/datensatze-in-einem-smarty-template-ausgeben/</link>
		<comments>http://hihn.org/2007/12/datensatze-in-einem-smarty-template-ausgeben/#comments</comments>
		<pubDate>Mon, 24 Dec 2007 21:34:32 +0000</pubDate>
		<dc:creator>rh</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.hihn.org/?p=21</guid>
		<description><![CDATA[Smarty bietet zwar if-, foreach- etc Schleifen aber keine while-Schleife, mit der man sehr einfach viele Datensätze ausgeben kann. Richtig anspruchsvoll wird es, wenn man noch die Mysql-Klasse aus dem Zend Framework benutzt, da dort kein mysql_fetch_assoc() benutzt wird. Mit folgendem Code kann man einfach alle Results in einem Template ausgeben: php-Datei: $sql_img = "SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>Smarty bietet zwar if-, foreach- etc Schleifen aber keine while-Schleife, mit der man sehr einfach viele Datensätze ausgeben kann.<br />
Richtig anspruchsvoll wird es, wenn man noch die Mysql-Klasse aus dem <a href="http://framework.zend.com/">Zend Framework</a> benutzt, da dort kein <a href="http://php.net/mysql_fetch_assoc">mysql_fetch_assoc()</a> benutzt wird.</p>
<p>Mit folgendem Code kann man einfach alle Results in einem Template ausgeben:</p>
<p>php-Datei:</p>
<pre>
$sql_img	= "SELECT * FROM rd_bilder";
$result 	= $db->fetchAll($sql_img);

$s->assign("bilder", $result);
</pre>
<p>tpl-Datei:</p>
<pre>
{foreach from=$bilder|smarty:nodefaults item=v1}
	{$v1.name_new}
{/foreach}
</pre>
<p>Anscheind gibt es im Smarty-Code einen Bug, weshalb man nodefaults einstellen muss, habe mich aber nicht näher damit beschäftigt.</p>
]]></content:encoded>
			<wfw:commentRss>http://hihn.org/2007/12/datensatze-in-einem-smarty-template-ausgeben/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty einrichten</title>
		<link>http://hihn.org/2007/12/smarty-einrichten/</link>
		<comments>http://hihn.org/2007/12/smarty-einrichten/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 17:26:20 +0000</pubDate>
		<dc:creator>rh</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.hihn.org/?p=20</guid>
		<description><![CDATA[Für mein neues Projekt habe ich mich dazu entschlossen, Smarty zu benutzen. Smarty ist &#8211; kurz gesagt &#8211; eine PHP-Klasse mit der man PHP-Code und HTML trennen kann. Es ist grundsätzlich sinnvoll, die lib-Dateien nicht in das library-Verzeichnis von PHP zu kopieren, sondern sie in den Projektordner zu kopieren. Gegeben ist der Projektordner &#8220;balduin&#8221; welcher [...]]]></description>
			<content:encoded><![CDATA[<p>Für mein neues Projekt habe ich mich dazu entschlossen, <a href="http://smarty.php.net/">Smarty</a> zu benutzen.<br />
Smarty ist &#8211; kurz gesagt &#8211; eine PHP-Klasse mit der man PHP-Code und HTML trennen kann.</p>
<p>Es ist grundsätzlich sinnvoll, die lib-Dateien nicht in das library-Verzeichnis von PHP zu kopieren, sondern sie in den Projektordner zu kopieren. </p>
<p>Gegeben ist der Projektordner &#8220;balduin&#8221; welcher folgende Ordnerstruktur bekommt:</p>
<pre>
/balduin/inc/
/balduin/lib/
/balduin/php/
/balduin/tpl/
/balduin/tpl_c/
</pre>
<p>In dem <strong>inc</strong>-Ordner kommen später Konfigurationsdateien rein, zum Beispiel die Zugangsdaten für die Datenbank.<br />
In dem <strong>lib</strong>-Ordner kommen die Dateien rein, die im <strong>lib</strong>-Ordner von Smarty drin sind (siehe INSTALL).<br />
Der <strong>php</strong> beinhaltet die php-Dateien. Er kann nach eigenem Gutdünken benannt werden.<br />
Im <strong>tpl</strong>-Ordner sind die Templates (HTML) Dateien drin.</p>
<p>Ich habe im tpl- und im php-Ordner jeweils noch weitere Ordner erstellt, also in diesem Fall ein Ordner für die Startseite (namens &#8220;index&#8221;):</p>
<pre>
/balduin/php/index/
/balduin/tpl/index
</pre>
<p>Darin befindet sich eine <strong>index.php</strong> bzw. <strong>index.tpl</strong>.</p>
<p>index.php</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot;color: #000000&quot;&gt;<br />
&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;assign&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;value&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//&amp;nbsp;Deklarierung&amp;nbsp;der&amp;nbsp;Variable&amp;nbsp;$test&amp;nbsp;mit&amp;nbsp;dem&amp;nbsp;Wert&amp;nbsp;&quot;value&quot;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;index/index.tpl&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;//&amp;nbsp;Pfad&amp;nbsp;zur&amp;nbsp;dazugehoerigen&amp;nbsp;Template-Datei&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;<br />
<br />
&lt;/span&gt;</div></div>
<p>Um die gerade deklarierte Variable auszugeben, reicht es, folgendes in die index.tpl zu schreiben:</p>
<pre>
{$test}
</pre>
<p>Aufgerufen wird alles über die <strong>index.php</strong> im Projektordner, welche folgenden Inhalt benötigt:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;span style=&quot;color: #000000&quot;&gt;<br />
&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;/**&amp;nbsp;smarty&amp;nbsp;*/&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_application_path&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;getcwd&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;require_once(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_application_path&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;/lib/Smarty/Smarty.class.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;new&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Smarty&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;compile_check&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;debugging&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;caching&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;default_modifiers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;array(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'escape:&quot;htmlall&quot;'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;template_dir&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_application_path&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'/tpl'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;compile_dir&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_application_path&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'/tpl_c'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$s&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;cache_dir&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_application_path&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'/tpl_cache'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sites&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;index&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&amp;nbsp;=&amp;nbsp;array(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Die&amp;nbsp;Home&amp;nbsp;Seite&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;php/index/index.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sites&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&amp;nbsp;=&amp;nbsp;array(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Die&amp;nbsp;Test&amp;nbsp;Seite&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;php/test/test.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;if(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;array_key_exists&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;s&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;],&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sites&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;))&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$include_file&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sites&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;s&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]][&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt;}&amp;nbsp;else&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$include_file&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sites&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;index&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;include(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$include_file&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;<br />
<br />
&lt;/span&gt;</div></div>
<p>In diesem Fall habe ich ausser der <strong>index</strong>- Datei noch eine <strong>test</strong>-Datei.<br />
Über folgende URL kann man die Seiten aufrufen:</p>
<p><strong>http://localhost/balduin/index.php?s=index</strong><br />
bzw<br />
<strong>http://localhost/balduin/index.php?s=test</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://hihn.org/2007/12/smarty-einrichten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

