<?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>advantage for programmers &#8211; Programming blog &#8211; website programming blog, blog on website programming .net, java , php and mor</title>
	<atom:link href="https://www.searchenginegenie.com/programming-blog/tag/advantage-for-programmers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.searchenginegenie.com/programming-blog</link>
	<description></description>
	<lastBuildDate>Tue, 11 Dec 2012 08:58:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.4</generator>
	<item>
		<title>Smarty for Programmers</title>
		<link>https://www.searchenginegenie.com/programming-blog/smarty-for-programmers/</link>
					<comments>https://www.searchenginegenie.com/programming-blog/smarty-for-programmers/#respond</comments>
		
		<dc:creator><![CDATA[Camilla]]></dc:creator>
		<pubDate>Wed, 07 May 2008 07:25:00 +0000</pubDate>
				<category><![CDATA[Programmer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[advantage for programmers]]></category>
		<guid isPermaLink="false">http://www.searchenginegenie.com/programming-blog/smarty-for-programmers/</guid>

					<description><![CDATA[The advantage for programmers is that they write the code in a PHP file without having to combine the instructions with HTML. Also, if the designer changes the layout of a page the programmer doesn&#8217;t have to change the code to suit the new layout since the functionalities won&#8217;t change. You perform your work in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span>The advantage for programmers is that they write the code in a PHP file without having to combine the instructions with HTML. Also, if the designer changes the layout of a page the programmer doesn&#8217;t have to change the code to suit the new layout since the functionalities won&#8217;t change. You perform your work in your files, assign to the templates all the values needed to print on the site and go out for a beer.</span></p>
<p>The PHP file you need to include the Smarty class <code><span style="font-size: 10;">require 'Smarty.class.php'. </span></code><span>After that you instantiate the smarty with </span><code><span style="font-size: 10;">$smarty = new Smarty. </span></code></p>
<p>To assign a variable to the template you need to<code><span style="font-size: 10;"> $smarty-&gt;assign('UserName', 'Jeff Adams'). </span></code><span>After everything is finished you call the method and to display the template</span><code><span style="font-size: 10;"> $smarty-&gt;display('index.tpl').</span></code></p>
<p>A sample code like this (index.php) :</p>
<p>[php]<br />
&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;&lt;php &lt;/span&gt;<br />
 &lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;require &lt;/span&gt;&lt;span style=&quot;color: #dd0000; font-size: 10;&quot;&gt;&#8217;Smarty.class.php'&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;; &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$smarty &lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;= new &lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;Smarty&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;; &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$smarty&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;assign&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dd0000; font-size: 10;&quot;&gt;&#8217;Username'&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: #ff8000; font-size: 10;&quot;&gt;&#8217;Jeff Adams&#8217;); &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$smarty&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #dd0000; font-size: 10;&quot;&gt;&#8217;index.tpl'&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;); &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;?&gt; &lt;/span&gt;&lt;/code&gt;</p>
<p>[/php]</p>
<p><span><br />
</span></p>
<p>The template (index.tpl) like this:</p>
<p>[php]<br />
&lt;code&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&gt; &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&lt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&gt; &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;code&gt; &lt;/code&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;Welcome &lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$Username&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;} &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;code&gt;&lt;!&#8211;&lt;/code&#8211;&gt;&lt;/code&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&lt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&gt; &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;code&gt;&lt;!&#8211;&lt;/code&#8211;&gt;&lt;/code&gt;&lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&lt;!&#8211;&lt;/span&#8211;&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&lt;/&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;</p>
<p>[/php]</p>
<p>Also create an array in PHP an pass it to the template:</p>
<p>[php]<br />
&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$tmplate &lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;= array ( &lt;/span&gt;&lt;span style=&quot;color: #ff8000; font-size: 10;&quot;&gt;&#8217;UID&#8217;=&gt; &#8217;10&#8217;, &amp;&#8217;Name&#8217; =&gt; &#8216;Jeff Adams&#8217;, &#8216;Address&#8217;=&gt;&#8217;Home address&#8217;); &lt;/span&gt;&lt;/code&gt;&lt;span&gt;<br />
 &lt;/span&gt;&lt;code&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;$smarty&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;-&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000bb; font-size: 10;&quot;&gt;assign&lt;/span&gt;&lt;span style=&quot;color: #007700; font-size: 10;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #ff8000; font-size: 10;&quot;&gt;&#8217;info&#8217;, $tmplate);&lt;/span&gt;&lt;/code&gt;</p>
<p>[/php]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.searchenginegenie.com/programming-blog/smarty-for-programmers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.searchenginegenie.com @ 2024-06-21 15:05:02 by W3 Total Cache
-->