<?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>Chris Tate-Davies &#187; Zend</title>
	<atom:link href="http://www.christatedavies.co.uk/tag/zend/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christatedavies.co.uk</link>
	<description>An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring...</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:18:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Accessing controller data from a partial viewscript</title>
		<link>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/</link>
		<comments>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 15:43:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[partial]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[Viewscript]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=273</guid>
		<description><![CDATA[When using an inline partial viewscript in my form, I sometimes need access to data. I can accomplish this by using a setter and getter with a public function in my form. We&#8217;ll use the action &#8220;guinness&#8221; as the controller action in this example. application\modules\project\forms\guinness\base.php protected $_id; public function setId($id) { $this-&#62;_id = $id; return [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/' addthis:title='Accessing controller data from a partial viewscript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When using an inline partial viewscript in my form, I sometimes need access to data. I can accomplish this by using a setter and getter with a public function in my form. We&#8217;ll use the action &#8220;guinness&#8221; as the controller action in this example.</p>
<p><strong>application\modules\project\forms\guinness\base.php</strong></p>
<pre>protected $_id;

public function setId($id)
{
    $this-&gt;_id = $id;
    return $this;
}

public function getId()
{
    return $this-&gt;_id;
}

public function getPintCount()
{
    $model = new PubModel();
    return $model-&gt;countPints(this-&gt;getId());
}</pre>
<p><strong>application\modules\project\views\scripts\guinness\page.phtml</strong></p>
<pre>&lt;?=$this-&gt;render('_partial.phtml');?&gt;</pre>
<p><strong>application\modules\project\controllers\GuinnessController.php</strong></p>
<pre>&lt;?php
$form = new SomeForm();
$form-&gt;setId(123);
?&gt;</pre>
<p><strong>application\modules\projects\views\scripts\guinness\_partial.phtml</strong></p>
<pre>&lt;?=$this-&gt;element-&gt;getPintCount();?&gt;</pre>
<p>&nbsp;</p>
<p>This way I can get the content view my connected partials which in essence are a copy of the viewscript.</p>
<p>Seems a long way round, but it keeps everything nicely separated.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/' addthis:title='Accessing controller data from a partial viewscript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/11/17/accessing-controller-data-from-a-partial-viewscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN Externals &#8211; how to add them</title>
		<link>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/</link>
		<comments>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 10:16:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=231</guid>
		<description><![CDATA[When creating a Zend Framework site, its always best to keep the Zend library as an external source. This way you can keep the branch up-to-date with the release of Zend with a simple text file. To access the externals file, navigate to the root of your site: &#62; cd /var/www/mysite And add the external [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/' addthis:title='SVN Externals &#8211; how to add them ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When creating a Zend Framework site, its always best to keep the Zend library as an external source. This way you can keep the branch up-to-date with the release of Zend with a simple text file.</p>
<p>To access the externals file, navigate to the root of your site:</p>
<pre>&gt; cd /var/www/mysite</pre>
<p>And add the external to the svn:externals file. I am using the latest version of Zend Framework for this, but you can use any SVN source you like. Note, it <strong>has</strong> to be available as an SVN repository.</p>
<pre>&gt; svn propedit svn:externals .</pre>
<p>This will open a text editor.</p>
<p>To enter an external, just enter the local folder to download to, and the source SVN.</p>
<pre>destination source</pre>
<p>So, if I want my Zend Framework files to be saved in /var/www/mysite/library/Zend :</p>
<pre>library/Zend http://framework.zend.com/svn/framework/standard/tags/release-1.11.9/library/Zend/</pre>
<p>The first part is the local, second part is the URL of the repository.</p>
<p>Save and close.</p>
<p>Next time you do an update, svn will go and fetch the external files and save them for you.</p>
<p>Other externals are available, such as JQuery, various wikis and other JS sources.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/' addthis:title='SVN Externals &#8211; how to add them ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/09/08/svn-externals-how-to-add-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to pass data from Controller to Zend Form</title>
		<link>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/</link>
		<comments>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/#comments</comments>
		<pubDate>Fri, 20 May 2011 14:56:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Form]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=171</guid>
		<description><![CDATA[To pass data from your controller, to a Zend_Form, you can utilise the config parameters: $this-&#62;view-&#62;form = new Contact_Edit_Form(array('contactName' =&#62; 'Chris')); This will pass a very simple array to the form, and from within the form, $data = $this-&#62;getAttrib('contactName'); $data will then contain Chris<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/' addthis:title='How to pass data from Controller to Zend Form ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>To pass data from your controller, to a Zend_Form, you can utilise the config parameters:</p>
<pre>$this-&gt;view-&gt;form = new Contact_Edit_Form(array('contactName' =&gt; 'Chris'));</pre>
<p>This will pass a very simple array to the form, and from within the form,</p>
<pre>$data = $this-&gt;getAttrib('contactName');</pre>
<p>$data will then contain <strong>Chris</strong></p>
<p><strong><br />
</strong></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/' addthis:title='How to pass data from Controller to Zend Form ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/05/20/how-to-pass-data-from-controller-to-zend-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Console &#8211; get values passed</title>
		<link>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/</link>
		<comments>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/#comments</comments>
		<pubDate>Wed, 11 May 2011 14:27:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=165</guid>
		<description><![CDATA[When using a CLI script with options, I like to use the Zend_Console. If my options are as follows: $console = new Zend_Console_Getopt( array( 'i-s' =&#62; 'test option 1', 'e' =&#62; 'test option 2') ); For instance, &#62; php myScript.php -i OPTION To get the &#8220;OPTION&#8221; string for the -i parameter $arg = $console-&#62;getOption('i'); $arg [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/' addthis:title='Zend Console &#8211; get values passed ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>When using a CLI script with options, I like to use the Zend_Console.</p>
<p>If my options are as follows:</p>
<pre>$console = new Zend_Console_Getopt(
    array(
        'i-s'  =&gt; 'test option 1',
        'e'    =&gt; 'test option 2')
    );</pre>
<p>For instance,</p>
<pre>&gt; php myScript.php -i OPTION</pre>
<p>To get the &#8220;OPTION&#8221; string for the -i parameter</p>
<pre>$arg = $console-&gt;getOption('i');</pre>
<p>$arg will now contain the passed option, but if none was passed, it will be NULL</p>
<p>When outlining the available options that can be used with your script, you use the following syntax:</p>
<pre>long|short  =&gt; description;</pre>
<pre>test|t =&gt; 'Test the script';</pre>
<p>You can use,</p>
<pre>&gt; php myScript.php -t</pre>
<p>or</p>
<pre>&gt; php myScript.php --test</pre>
<p>to run the -test parameter. You can also pass values, such as an integer or a string:</p>
<pre>'test|t=i' =&gt; 'Option with required integer parameter';</pre>
<pre lang="x-western">'test|t-s' =&gt; 'Option with optional string parameter'</pre>
<p>For more information, refer to the Zend Documentation : <a href="http://framework.zend.com/manual/en/zend.console.getopt.introduction.html" target="_blank">http://framework.zend.com/manual/en/zend.console.getopt.introduction.html</a></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/' addthis:title='Zend Console &#8211; get values passed ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2011/05/11/zend-console-get-values-passed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Date &#8211; difference between 2 dates</title>
		<link>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/</link>
		<comments>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 15:04:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=109</guid>
		<description><![CDATA[I keep having trouble with this simple calculation! So, here is a little example to get the amount of days between now and the next occurance of July 1st. //set up the 2 date objects $now = new Zend_Date(); $next = new Zend_Date(); //we want July 1st $next-&#62;setDay(1)-&#62;setMonth(7); //if we are currently after july this [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/' addthis:title='Zend_Date &#8211; difference between 2 dates ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I keep having trouble with this simple calculation! So, here is a little example to get the amount of days between now and the next occurance of July 1st.</p>
<pre>
<div id="_mcePaste">//set up the 2 date objects</div>
<div id="_mcePaste">$now = new Zend_Date();</div>
<div id="_mcePaste">$next = new Zend_Date();</div>
<div id="_mcePaste">//we want July 1st</div>
<div id="_mcePaste">$next-&gt;setDay(1)-&gt;setMonth(7);</div>
<div id="_mcePaste">//if we are currently after july this year</div>
<div id="_mcePaste">if ($now-&gt;get(Zend_Date::MONTH) &gt;= 7) {</div>
<div id="_mcePaste">    //we need to work it out til next July</div>
<div id="_mcePaste">    $next-&gt;setYear($now-&gt;get(Zend_Date::YEAR) + 1);</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">else {</div>
<div id="_mcePaste">    //this july is fine</div>
<div id="_mcePaste">    $next-&gt;setYear($now-&gt;get(Zend_Date::YEAR));</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">$diff = $next-&gt;sub($now)-&gt;toValue();</div>
<div id="_mcePaste">return $diff / 60 / 60 / 24;</div>
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/' addthis:title='Zend_Date &#8211; difference between 2 dates ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/10/01/zend_date-difference-between-2-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing the Zend_Application from a page</title>
		<link>http://www.christatedavies.co.uk/2010/07/27/accessing-the-zend_application-from-a-page/</link>
		<comments>http://www.christatedavies.co.uk/2010/07/27/accessing-the-zend_application-from-a-page/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 12:06:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://www.christatedavies.co.uk/?p=95</guid>
		<description><![CDATA[If, like me, you need to access some Zend_Application resources (such as multidb resources) &#8211; then you need a reference to the Zend_Application and the bootstrap. I use this: if (null == $this-&#62;_application) { $this-&#62;_application = Zend_Controller_Front::getInstance() -&#62;getParam('bootstrap'); }<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/07/27/accessing-the-zend_application-from-a-page/' addthis:title='Accessing the Zend_Application from a page ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>If, like me, you need to access some Zend_Application resources (such as multidb resources) &#8211; then you need a reference to the Zend_Application and the bootstrap. I use this:</p>
<pre>if (null == $this-&gt;_application)
{
    $this-&gt;_application = Zend_Controller_Front::getInstance()
         -&gt;getParam('bootstrap');
}</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://www.christatedavies.co.uk/2010/07/27/accessing-the-zend_application-from-a-page/' addthis:title='Accessing the Zend_Application from a page ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.christatedavies.co.uk/2010/07/27/accessing-the-zend_application-from-a-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

