<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?316</link>
<title><![CDATA[ArthurXF经验传授smarty变量连接解决方案]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[PHP]]></category>
<pubDate>Fri, 29 Feb 2008 17:30:56 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?316</guid> 
<description>
<![CDATA[ 
	<p>　　此文章由ArthurXF(肖飞)倾情奉献!<br />　　我们在使用smarty的时候,经常会碰到变量组合成新变量的时候,例如:$aaa$b,$b是可变值,我们需要得到$aaa1,$aaa2,$aaa3等变量.但是在smarty中,这样的变量连接写法是不允许的.<br /><br />针对这样的问题,我给出下面几种情况的解决方案.<br />注:&lt;?{和}?&gt;是我定义的smarty定界符,等同于{和},希望大家理解.<br /><div class="quote"><div class="quote-title">引用</div><div class="quote-content">1.针对数组的变量连接问题:<br />&lt;?php<br />$arrMType = array();<br />$arrMType[1] = '高交会展';<br />$arrMType[2] = '学术会议';<br />$arrData[id] = 1;<br />?&gt;<br />在smarty中.<br />$arrMType[$arrData.id]是错误的.<br />解决方案:<br />&lt;?{foreach from=$arrType key=key item=value}?&gt;<br />&lt;?{if $key == $arrData.type_id}?&gt;&lt;?{$value}?&gt;&lt;?{/if}?&gt;<br />&lt;?{/foreach}?&gt;<br /><br /><br />2.针对文件引用的变量连接问题:<br />&lt;?PHP<br />$page=&quot;index&quot;;<br />?&gt; <br />在smarty中,下面的写法都是错误的.<br />&lt;?{include file=$page.html}?&gt; //这样不能执行成功 <br />&lt;?{include file=$page&#124;cat:&quot;.html&quot;}?&gt; //还是不行 <br />解决方案:<br />&lt;?{include file=&quot;`$page`.html&quot;}?&gt; <br /><br /><br />3.针对函数传递的变量连接问题:<br />&lt;?PHP<br />$arrGWeb['module_id'] = 'news';<br />?&gt;<br />要在smarty中实现:<br />&lt;?{url url = &quot;/news/list?type_id=1&quot;}?&gt;<br />错误的写法:<br />&lt;?{url url = &quot;/$arrGWeb.module_id/list?type_id=1&quot;}?&gt;<br />正确的写法:<br />&lt;?{url url = &quot;/`$arrGWeb.module_id`/list?type_id=1&quot;}?&gt;<br />注意:&quot;`&quot;这个符号,是数字1前面的那个符号,不是单引号.<br /></div></div><br /><br /></p><div class="announce-content">ArthurXF从业10年的CTO,受上海非凡学院邀请,进行PHP,CSS,FREEBSD等网络技能授课培训,有意向参加的,请联系. </div><br/>Tags - <a href="tag.php?tag=smarty%E5%8F%98%E9%87%8F%E8%BF%9E%E6%8E%A5" rel="tag">smarty变量连接</a> , <a href="tag.php?tag=php" rel="tag">php</a> , <a href="tag.php?tag=smarty" rel="tag">smarty</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?316&amp;guid=0#topreply</link>
<title><![CDATA[[评论] ArthurXF经验传授smarty变量连接解决方案]]></title> 
<author>hfly &lt;hap-for-ever@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 18 Jun 2008 06:00:03 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?316&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	$GLOBALS[&#039;smarty&#039;]-&gt;assign(&#039;cat_goods_&#039; . $cat_id, $goods);<br/>我要实现这个功能<br/>要在模版中怎么写啊！？？
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?316&amp;guid=1#topreply</link>
<title><![CDATA[[评论] ArthurXF经验传授smarty变量连接解决方案]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 21 Jun 2008 04:31:59 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?316&amp;guid=1#topreply</guid> 
<description>
<![CDATA[ 
	模板中可以按照第三种方法写。如果只是在模板里写字符串拼接可以写成{&quot;cat_goods_&#96;$cat_id&#96;&quot;},或者cat_good_{$cat_id}
]]>
</description>
</item>
</channel>
</rss>