<?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>Kane&#039;s Blog &#187; smarty</title>
	<atom:link href="http://iamkane.com/index.php/archives/tag/smarty/feed" rel="self" type="application/rss+xml" />
	<link>http://iamkane.com</link>
	<description>Bug can be anywhere,Can you find it?</description>
	<lastBuildDate>Mon, 21 Jun 2010 11:05:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ZendFramework1.97 和 Smarty 结合并用的方法</title>
		<link>http://iamkane.com/index.php/archives/159</link>
		<comments>http://iamkane.com/index.php/archives/159#comments</comments>
		<pubDate>Fri, 22 Jan 2010 03:48:54 +0000</pubDate>
		<dc:creator>Kane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[zendframework]]></category>
		<category><![CDATA[ZF]]></category>

		<guid isPermaLink="false">http://iamkane.com/?p=159</guid>
		<description><![CDATA[网上搜了一堆结合的方法都是 ZF1.8 以下的..自己研究了2天终于成功了。记录一下..
目录结构是Zend Studio &#8211; 7.1.1 自建生成的，其中 template 和 templates 是我自己加上去给Smarty用的，也可以说是替换ZF 的View层。如下图

第一步 配置application.ini

把 resources.frontController.noViewRenderer = 1 加到 production 里，然后在staging : production 里面加上smarty的配置信息


[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH &#34;/../library&#34;
bootstrap.path = APPLICATION_PATH &#34;/Bootstrap.php&#34;
bootstrap.class = &#34;Bootstrap&#34;
resources.frontController.controllerDirectory = APPLICATION_PATH &#34;/controllers&#34;
resources.frontController.noViewRenderer = 1

[staging : production]
smarty.class_path = &#34;Smarty/Smarty.class.php&#34;
smarty.left_delimiter = &#34;{&#34;
smarty.right_delimiter = &#34;}&#34;
smarty.template_dir =APPLICATION_PATH &#34;/template/&#34;
smarty.compile_dir =APPLICATION_PATH &#34;/templates_c/&#34;
smarty.cache_dir = APPLICATION_PATH &#34;/cache/&#34;
smarty.cache_lifetime = [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff9900;">网上搜了一堆结合的方法都是 ZF1.8 以下的..自己研究了2天终于成功了。记录一下..</span></strong></p>
<p>目录结构是Zend Studio &#8211; 7.1.1 自建生成的，其中 template 和 templates 是我自己加上去给Smarty用的，也可以说是替换ZF 的View层。如下图</p>
<p><a href="http://iamkane.com/wp-content/uploads/2010/01/zf_tree.png"><img class="alignnone size-full wp-image-160" title="zf_tree" src="http://iamkane.com/wp-content/uploads/2010/01/zf_tree.png" alt="" width="261" height="369" /></a></p>
<p><strong>第一步 配置application.ini</strong></p>
<p>
把 resources.frontController.noViewRenderer = 1 加到 production 里，然后在staging : production 里面加上smarty的配置信息
</p>
<pre class="brush: plain;">
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH &quot;/../library&quot;
bootstrap.path = APPLICATION_PATH &quot;/Bootstrap.php&quot;
bootstrap.class = &quot;Bootstrap&quot;
resources.frontController.controllerDirectory = APPLICATION_PATH &quot;/controllers&quot;
resources.frontController.noViewRenderer = 1

[staging : production]
smarty.class_path = &quot;Smarty/Smarty.class.php&quot;
smarty.left_delimiter = &quot;{&quot;
smarty.right_delimiter = &quot;}&quot;
smarty.template_dir =APPLICATION_PATH &quot;/template/&quot;
smarty.compile_dir =APPLICATION_PATH &quot;/templates_c/&quot;
smarty.cache_dir = APPLICATION_PATH &quot;/cache/&quot;
smarty.cache_lifetime = 600
smarty.caching = 0

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
</pre>
<p><strong>第二步 修改Bootstrap.php</strong></p>
<p>添加下面的代码</p>
<pre class="brush: php;">

public function _initView(){
        $config = new Zend_Config_Ini(APPLICATION_PATH. '/configs/application.ini', 'staging');
        require_once $config-&gt;smarty-&gt;class_path;

        $smarty = new Smarty();
        $smarty-&gt;left_delimiter = $config-&gt;smarty-&gt;left_delimiter;
        $smarty-&gt;right_delimiter = $config-&gt;smarty-&gt;right_delimiter;
        $smarty-&gt;template_dir = $config-&gt;smarty-&gt;template_dir;
        $smarty-&gt;compile_dir = $config-&gt;smarty-&gt;compile_dir;
        $smarty-&gt;cache_dir = $config-&gt;smarty-&gt;cache_dir;
        $smarty-&gt;cache_lifetime = $config-&gt;smarty-&gt;cache_lifetime;
        $smarty-&gt;caching = $config-&gt;smarty-&gt;caching;

        Zend_Registry::set('smarty', $smarty);
    }
</pre>
<p><strong>第三步 在 controller 测试 </strong></p>
<p>添加下面的代码</p>
<pre class="brush: php;">
 public function indexAction()
    {
    	$template='test/test.html';
    	$this-&gt;smarty = Zend_Registry::get('smarty');
		$this-&gt;smarty-&gt;assign('test', 'iamkane');
		$this-&gt;smarty-&gt;display($template);

    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://iamkane.com/index.php/archives/159/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
