<?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>أحمد فوزي &#187; smarty template engine</title>
	<atom:link href="http://www.ahmedfawzy.com/archives/category/smarty-template-engine/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ahmedfawzy.com</link>
	<description>مدونة ووردبريس عربية أخرى</description>
	<lastBuildDate>Sun, 29 Jan 2012 20:41:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>شرح smarty template engine</title>
		<link>http://www.ahmedfawzy.com/archives/14</link>
		<comments>http://www.ahmedfawzy.com/archives/14#comments</comments>
		<pubDate>Sun, 07 Oct 2007 19:36:32 +0000</pubDate>
		<dc:creator>ahmed</dc:creator>
				<category><![CDATA[smarty template engine]]></category>

		<guid isPermaLink="false">http://www.ahmedfawzy.com/archives/14</guid>
		<description><![CDATA[بسم الله الرحمن الرحيم [ad#Google Adsense] منذ بداية مشواري مع لغة ال php وحتي الان بحثت عن شرح لكيفية العمل مع ال smarty ولكني للاسف لم اجد اي مبرمج عربي تكلم عنه بتمعن ولكن الجميع يكتفي بالبداية فقط ففكرت في &#8230; <a href="http://www.ahmedfawzy.com/archives/14">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p align="center"><strong>بسم الله الرحمن الرحيم</strong></p>
<p>[ad#Google Adsense]</p>
<p align="right">منذ بداية مشواري مع لغة ال php وحتي الان بحثت عن شرح لكيفية العمل مع ال smarty ولكني للاسف لم اجد اي مبرمج عربي تكلم عنه بتمعن ولكن الجميع يكتفي بالبداية فقط ففكرت في ان اهدي هذا الشرح لمنتدي سوالف لعل يكون به منفعة لاحد أعضاءه او زواره بسم الله سنبدأ</p>
<p>أولا عليك بتحميل نسخه من الرابط التالي <a rel="nofollow" target="_blank" href="http://smarty.php.net/download.php"><strong><font color="#333399">smarty</font></strong></a></p>
<p>ثانيا نفك الضغط ونبدأ بكتابة اول كود لنا مع ال smarty ونفتح اول صفحاتنا البرمجية ونكتب بأعلاها هذا الكود</p>
<p><span id="more-14"></span></p>
<p>كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p style="text-align: left" dir="ltr"><code><font color="#0000bb">&lt;?php<br />
define</font><font color="#007700">(</font><font color="#dd0000">'SMARTY_DIR'</font><font color="#007700">,</font><font color="#dd0000">'مكان فولدر smarty'</font><font color="#007700">);<br />
require_once(</font><font color="#0000bb">SMARTY_DIR </font><font color="#007700">. </font><font color="#dd0000">'Smarty.class.php'</font><font color="#007700">);<br />
</font><font color="#0000bb">$smarty </font><font color="#007700">= new </font><font color="#0000bb">Smarty</font><font color="#007700">();<br />
</font><font color="#0000bb">?&gt;</font> </code><br />
ما معني هذا</p>
<p>اول شيء نضع مسار ملف Smarty.class.php<br />
والسطر الثاني لنخبره اننا سنستعملها الان
</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p style="text-align: left" dir="ltr"><code><font color="#0000bb"> $smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">template_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر التمبلت '</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">compile_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر الكاش للتمبلت'</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">config_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر الكونفيج'</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">cache_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر الكاش'</font><font color="#007700">;<br />
</font></code></p>
<p>هذا بالنسبه للثوابت التي سوف تكون معنا بعون الله في جميع<br />
تعاملاتنا مع ال smarty  </p>
<p><strong>بدايتك مع اول صفحه مع ال smarty</strong><br />
في البداية نود ان نعرف كيف نتعامل مع المتغيرات variables<br />
ولتعيين متغير جديد يكتب بهذه الطريقه
</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p style="text-align: left" dir="ltr"><code><font color="#0000bb"> $smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">assign</font><font color="#007700">(</font><font color="#dd0000">'name'</font><font color="#007700">,</font><font color="#dd0000">'أحمد'</font><font color="#007700">);<br />
</font><font color="#0000bb">بدلاً من<br />
$name</font><font color="#007700">=</font><font color="#dd0000">'أحمد'</font><font color="#007700">;<br />
</font></code></p>
<p>وعند كتابتها في التمبلت تكتب بهذه الطريقة لعرض قيمة المتغير
</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p align="right" style="text-align: left" dir="ltr"><code><font color="#0000bb"> </font><font color="#007700">{$</font><font color="#0000bb">name</font><font color="#007700">}<br />
</font></code><br />
وبذلك نجد انفسنا الان قادرين<br />
علي كتابة اول صفحة لنا باستخدام تقنية smarty ان صح القول
</p>
<p align="right">أول شيء نقوم بعمل صفحة نسميها مثلا index.php ونكتب فيها الأتي</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p style="text-align: left" dir="ltr"><code><font color="#0000bb">&lt;?php<br />
define</font><font color="#007700">(</font><font color="#dd0000">'SMARTY_DIR'</font><font color="#007700">,</font><font color="#dd0000">'مكان فولدر smarty'</font><font color="#007700">);<br />
require_once(</font><font color="#0000bb">SMARTY_DIR </font><font color="#007700">. </font><font color="#dd0000">'Smarty.class.php'</font><font color="#007700">);<br />
</font><font color="#0000bb">$smarty </font><font color="#007700">= new </font><font color="#0000bb">Smarty</font><font color="#007700">();<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">template_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر التمبلت '</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">compile_dir </font><font color="#007700">= </font><font color="#dd0000">' مكان فولدر التمبلت بعد معالجته'</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">config_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر الكونفيج'</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">cache_dir </font><font color="#007700">= </font><font color="#dd0000">'مكان فولدر الكاش'</font><font color="#007700">;<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">assign</font><font color="#007700">(</font><font color="#dd0000">'name'</font><font color="#007700">,</font><font color="#dd0000">'أحمد'</font><font color="#007700">);<br />
</font><font color="#ff8000">//هذا لعرض ملف التمبلت واسمه هنا هو index.tpl<br />
</font><font color="#0000bb">$smarty</font><font color="#007700">-&gt;</font><font color="#0000bb">display</font><font color="#007700">(</font><font color="#dd0000">'index.tpl'</font><font color="#007700">);<br />
</font><font color="#0000bb">?&gt;</font> </code><br />
وبعد ذلك وفي مجلد التمبلت الذي حددنا مساره نكتب هذا
</p>
<p style="margin-bottom: 2px" class="smallfont">كود HTML:</p>
<p align="left"><font color="#000080">&lt;!DOCTYPE // html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</font> <font color="#000080">&lt;html dir=</font><font color="#0000ff">&#8220;rtl&#8221;</font>&gt; <font color="#000080">&lt;head&gt;</font> <font color="#000080">&lt;title&gt;</font>أول تجربه مع smarty<font color="#000080">&lt;/title&gt;</font> <font color="#000080">&lt;meta http-equiv=&#8221;Content-Type&#8221; content=</font><font color="#0000ff">&#8220;text/html; charset=windows-1256&#8243;</font> /&gt; <font color="#000080">&lt;/head&gt;</font> <font color="#000080">&lt;body&gt;</font> الأسم المخزن هو  {$name}  <font color="#000080">&lt;/body&gt;</font> <font color="#000080">&lt;/html&gt;</font><br />
وهذا شرح مبسط لطريقة كتابة المتغيرات</p>
<p><strong>التعليقات</strong><br />
كيف نكتب تعليقاً في ال smarty الأمر بسيط جدا فقط بهذه الطريقه
</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code><code style="white-space: nowrap"></code></p>
<p align="right" style="text-align: left" dir="ltr"><code><font color="#0000bb"> </font><font color="#007700">{*<br />
</font><font color="#0000bb">هنا نكتب التعليق الذي نريده سواء سطر واحد أو عده أسطر<br />
</font><font color="#007700">*}<br />
</font></code></p>
<p><code><font color="#000000"><strong>الادراج</strong><br />
كيف يمكننا ادراج ملف في ملف التمبلت<br />
فلنفرض مثلا عندنا ملف هيدر وملف فوتر ونريد ادراجهما<br />
داخل ملف التمبلت الخاص بالانديكس كيف نفعل ذلك</font></code><code><font color="#000000"> </font></code><code></code></p>
<p><code></code><code></code><code></code><code></code><code></code><code></code><code></code>
</p>
<p style="margin-bottom: 2px" class="smallfont">كود PHP:</p>
<p><code style="white-space: nowrap"></code><code></code></p>
<p align="left"><code style="white-space: nowrap"></code><code> <font color="#007700">{include </font><font color="#0000bb">file</font><font color="#007700">=</font><font color="#dd0000">"header.tpl"</font><font color="#007700">}</font></code></p>
<p><code></code><code><font color="#007700"> </font></code><code style="white-space: nowrap"></code><code></code><code><font color="#0000bb">هنا كود ال html </font></code><code></code><code><font color="#0000bb"> </font></code><code></code><code></code><code></code><code></code><code></code></p>
<p align="left"><font color="#007700">{include </font><font color="#0000bb">file</font><font color="#007700">=</font><font color="#dd0000">&#8220;footer.tpl&#8221;</font><font color="#007700">}<br />
</font>
</p>
<p align="right" style="text-align: left" dir="ltr">&nbsp;</p>
<p>مع الاخذ في الاعتبار ان header.tpl هو اسم ملف الهيدر و footer.tpl هو اسم ملف الفوتر</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ahmedfawzy.com/archives/14/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

