<?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>TK Studios &#187; web development</title>
	<atom:link href="http://www.tkstudios.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tkstudios.com</link>
	<description>Web Application Design &#38; Development</description>
	<lastBuildDate>Mon, 20 Jun 2011 16:07:28 +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>Disable WP&#8217;s Automatic Paragraphs</title>
		<link>http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/</link>
		<comments>http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 16:07:28 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=266</guid>
		<description><![CDATA[A quick hack to disable the wpautop() function&#8217;s tendency to mangle your WordPress-based HTML posts with extra markup: Add the following to your functions.php: function custom_autop($p, $br = 1) { if (stristr($p, '&#60;!--noautop--&#62;')) { return str_ireplace('&#60;!--noautop--&#62;', '', $p); } else {     return wpautop($p, $br);   } } remove_filter('the_content','wpautop'); add_filter('the_content','custom_autop'); That&#8217;s it. Now when [...]]]></description>
			<content:encoded><![CDATA[<p>A quick hack to disable the <strong>wpautop()</strong> function&#8217;s tendency to mangle your WordPress-based HTML posts with extra markup:</p>
<p>Add the following to your <strong>functions.php</strong>:</p>
<pre>function custom_autop($p, $br = 1) {
  if (stristr($p, '&lt;!--noautop--&gt;')) {
    return str_ireplace('&lt;!--noautop--&gt;', '', $p);
  } else {
    return wpautop($p, $br);
  }
}
remove_filter('the_content','wpautop');
add_filter('the_content','custom_autop');</pre>
<p>That&#8217;s it. Now when you add <strong>&lt;!&#8211;noautop&#8211;&gt; </strong>to a post, it&#8217;ll disable the wpautop() function.</p>
<p>Incidentally, wpautop has a parameter called &#8220;$pee&#8221; and a loop that reads &#8220;foreach( $pees as $tinkle )&#8221; &#8230;</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Disable+WP%E2%80%99s+Automatic+Paragraphs+http%3A%2F%2Fis.gd%2FtHw2Me+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Disable+WP%E2%80%99s+Automatic+Paragraphs+http%3A%2F%2Fis.gd%2FtHw2Me+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/&amp;title=Disable+WP%E2%80%99s+Automatic+Paragraphs" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2011/06/20/disable-wps-automatic-paragraphs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick JS experiment: Function Overhead</title>
		<link>http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/</link>
		<comments>http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 17:27:44 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[FOR SCIENCE]]></category>
		<category><![CDATA[micro-optimization]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=241</guid>
		<description><![CDATA[Probably common knowledge, but I just slapped together a quick test script to determine what kind of overhead there is between a) writing a function inline, b) keeping the function as part of an object (say, utility.isObject), and c) same as b, but get a reference to the function first. Each approach was iterated a [...]]]></description>
			<content:encoded><![CDATA[<p>Probably common knowledge, but I just slapped together a quick test script to determine what kind of overhead there is between a) writing a function inline, b) keeping the function as part of an object (say, utility.isObject), and c) same as b, but get a reference to the function first. Each approach was iterated a total of <em>100,000,000 times</em> to get usable time values. Tests were performed in Chrome 7, so YMMV. <span id="more-241"></span></p>
<p><strong>Results:</strong></p>
<p><strong>A:</strong> typeof obj == &#8220;object&#8221; : <strong>439 msec</strong><br />
<strong>B:</strong> util.isObj(obj) : <strong>1228 msec</strong> <em>(where util = { isObj : function(o) { return typeof o == &#8220;object&#8221;; } }) </em><br />
<strong>C:</strong> isObj(obj) : <strong>1155 msec</strong> <em>(where B and isObj = util.isObj)</em></p>
<p><strong>Conclusions: </strong></p>
<p>First, remember that these are looping over <strong>100 million</strong> iterations. This kind of research might be useful for a worker thread, but it&#8217;s not terribly useful for day to day stuff.</p>
<p>The big conclusion here is if you&#8217;re only going to call a function from one or two places, or it&#8217;s very short, skipping the function and putting the code inline will save you about 60%, but it&#8217;s really only significant if you&#8217;re calling that function millions of times.</p>
<p>The second conclusion is that if you must use a function for something like this (millions of calls), you can save a tiny bit—almost completely insignificant—of time by getting a reference to that function. Keep in mind that this micro-optimization<em> only works if the function you&#8217;re calling doesn&#8217;t require context</em>. If you have to use the <em>.call</em> or <em>.apply</em> methods to add context, this approach is actually about <strong>17x slower</strong>.</p>
<p>Actual testing code at <a href="http://jsfiddle.net/jsylvanus/tTsXp/">http://jsfiddle.net/jsylvanus/tTsXp/</a></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Quick+JS+experiment%3A+Function+Overhead+http%3A%2F%2Fis.gd%2FqQRGRd+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Quick+JS+experiment%3A+Function+Overhead+http%3A%2F%2Fis.gd%2FqQRGRd+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/&amp;title=Quick+JS+experiment%3A+Function+Overhead" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/11/03/quick-js-experiment-function-overhead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpScenario &amp; Listy.us updates</title>
		<link>http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/</link>
		<comments>http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 17:58:59 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Listy]]></category>
		<category><![CDATA[phpScenario]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[changelog]]></category>
		<category><![CDATA[listy.us]]></category>
		<category><![CDATA[qunit]]></category>
		<category><![CDATA[requirejs]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=234</guid>
		<description><![CDATA[First, phpScenario has been updated to 0.1.1 (change log here), so that&#8217;s cool. It helps when the library you release actually works, right? Second, I&#8217;ve been posting some related tutorials in the project&#8217;s forums: Getting started with phpScenario &#038; Zend Framework (updated for 0.1.1) Configuration example for PDO adapter Working with Identity Providers (new for [...]]]></description>
			<content:encoded><![CDATA[<p>First, phpScenario has been updated to 0.1.1 (<a href="http://www.phpscenario.org/forum/index.php?topic=6.0">change log here</a>), so that&#8217;s cool. It helps when the library you release actually <strong>works</strong>, right?</p>
<p>Second, I&#8217;ve been posting some related tutorials in the project&#8217;s forums:</p>
<ul>
<li><a href="http://www.phpscenario.org/forum/index.php?topic=4.0">Getting started with phpScenario &#038; Zend Framework</a> (updated for 0.1.1)</li>
<li><a href="http://www.phpscenario.org/forum/index.php?topic=3.0">Configuration example for PDO adapter</a></li>
<li><a href="http://www.phpscenario.org/forum/index.php?topic=7.0">Working with Identity Providers</a> (new for 0.1.1)</a></li>
</ul>
<p>So, if you&#8217;re interested in split testing via php, I&#8217;d recommend checking the project and tutorials out.</p>
<p>Third, I&#8217;m finally getting started on the rewrite of Listy.us&#8217;s editor. Where the old editor was a single, sparsely-commented 1400-line javascript file, the new one is spread across several files using RequireJS, and uses QUnit for unit testing. It is, essentially, a project in itself, and I&#8217;m finding it much, much nicer to work with.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=phpScenario+%26+Listy.us+updates+http%3A%2F%2Fis.gd%2FusEs0P+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=phpScenario+%26+Listy.us+updates+http%3A%2F%2Fis.gd%2FusEs0P+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/&amp;title=phpScenario+%26+Listy.us+updates" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/10/27/phpscenario-listy-us-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing phpScenario</title>
		<link>http://www.tkstudios.com/2010/10/18/introducing-phpscenario/</link>
		<comments>http://www.tkstudios.com/2010/10/18/introducing-phpscenario/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 17:21:44 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[phpScenario]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[a/b testing]]></category>
		<category><![CDATA[conversion optimization]]></category>
		<category><![CDATA[split testing]]></category>
		<category><![CDATA[user experience]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=208</guid>
		<description><![CDATA[Last night I launched the project I&#8217;d mentioned a couple days ago. It&#8217;s a fairly early version of a free (BSD licensed) split testing library I&#8217;ve named phpScenario. The usage has changed a little bit since then; the code samples should still work, but they&#8217;ve been simplified even further so the main tasks (getting a [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I launched the project I&#8217;d <a href="http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/">mentioned a couple days ago</a>. It&#8217;s a fairly early version of a free (BSD licensed) split testing library I&#8217;ve named <strong>phpScenario</strong>. The usage has changed a little bit since then; the code samples should still work, but they&#8217;ve been simplified even further so the main tasks (getting a treatment, setting it as complete, rendering results) can be done with single statements.</p>
<p>You can check out the free split testing library in all it&#8217;s beta glory at <a href="http://www.phpscenario.org/">www.phpscenario.org</a> and post any questions on the <a href="http://www.phpscenario.org/forum/">discussion boards</a>. It&#8217;s version 0.1 beta, as in <em>&#8220;Well, it works for me, but could probably use some tuning.&#8221;</em></p>
<p><span id="more-208"></span></p>
<p>Split testing, or A/B testing, is a method for testing goal-oriented theories. Essentially you say &#8220;I think (blank) will be more effective than (blank),&#8221; and then collect data to verify or disprove that hypothesis. In its simplest form, you&#8217;re just testing a 50/50 between two theories, a control and an alternate version. phpScenario assumes that this is the most desirable route and has defaults as follows:</p>
<ul>
<li>50/50 split test between control (&#8220;default&#8221;) and &#8220;alternate&#8221;</li>
<li>assumes you want to use session ID as the identifier</li>
<li>assumes a certain database structure</li>
</ul>
<p>Basically all you have to provide it with is a data adapter (two are currently provided in the library, for Zend_Db and PDO) and the database info, and you can fire away with one-liner testing.</p>
<p>The library makes room for more elaborate testing however, by allowing you to define classes for special cases, inheriting from Scenario_Experiment. It&#8217;s an object-oriented library, so I&#8217;ve tried to take advantage of that where possible. You can also define your own Identity objects, if you&#8217;d prefer to use, for example, a user ID rather than the session id as an identifier for testing.</p>
<p>As stated in the previous post, there&#8217;s an abstract renderer object and an included renderer that outputs XML, and optionally translated that XML via included or provided XSL translation files. The included one translates the data to a fairly simple HTML table, including z-score so you can judge just how reliable the data is.</p>
<h4>How to Install</h4>
<ul>
<li><a href="http://www.phpscenario.org/download.php">Download</a> the package and run <em>database.sql</em> against the database you&#8217;re intending to use. There&#8217;s an example of how to do so using the mysql command line tool in <em>README.txt</em> in the package.</li>
<li>Include and <a href="http://www.phpscenario.org/docs/Scenario/Scenario_Core.html#config">configure the core</a> per the documentation. If you&#8217;re not using something with a bootstrap like Zend Framework, you should probably put all the configuration stuff in one file and just <em>require_once</em> that file whenever you need to do Scenario calls.</li>
<li><strong>That&#8217;s it.</strong> Start making calls to the library.</li>
</ul>
<p>It&#8217;s a pretty straightforward setup process. I basically designed the library to solve my own problems, and wanted something I could just throw into any given project and have a working solution in under a minute. Add tables, configure core, and go. I figured I might as well make it something other folks can use as well.</p>
<p>Once you&#8217;ve got the core configured, you can see how easy it is to actually use the library on the <a href="http://www.phpscenario.org/">phpScenario site</a>.</p>
<p>Questions/comments/etc can go in the comments here or on the forums, I&#8217;ll answer both.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Introducing+phpScenario+http%3A%2F%2Fis.gd%2Fypu3Ef+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Introducing+phpScenario+http%3A%2F%2Fis.gd%2Fypu3Ef+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/18/introducing-phpscenario/&amp;title=Introducing+phpScenario" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/10/18/introducing-phpscenario/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpScenario, a split testing library</title>
		<link>http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/</link>
		<comments>http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 22:35:59 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[phpScenario]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[free stuff]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=173</guid>
		<description><![CDATA[I&#8217;m closing in on the first release of what you might call a by-product of Listy.us; phpScenario is a free split-testing library created out of the need to have a way of testing various ideas on Listy.us without relying on paid products or offsite solutions. I&#8217;m going to release it for free, though I haven&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m closing in on the first release of what you might call a by-product of Listy.us; <strong><a title="phpScenario: Free Split Testing Library for PHP" href="http://www.phpscenario.org/">phpScenario</a></strong><a title="phpScenario: Free Split Testing Library for PHP" href="http://www.phpscenario.org/"> is a free split-testing library</a> created out of the need to have a way of testing various ideas on Listy.us without relying on paid products or offsite solutions. I&#8217;m going to release it for <strong>free</strong>, though I haven&#8217;t chosen a license yet. (update: New BSD license!)</p>
<p><span id="more-173"></span></p>
<p>At the core, I wanted it to be as simple as possible to create new tests, but still have a good degree of flexibility. Basically by default, it assumes you want a A/B 50% split test using the php session ID as the identity. If you have a class defined as [Prefix_]TestName, it&#8217;ll load that as the experiment object instead of the default class, and you can do any additional cases (a/b/c/d?) and/or weighting in the treatment selection method. One treatment must always be named &#8220;default&#8221;.</p>
<p>The simplest possible usage case, after setting up your database, is essentially this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Scenario<span style="color: #339933;">::</span><span style="color: #004000;">IsControl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myExperiment'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// do something </span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// do something different</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Next, in your conversion point, you&#8217;d do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Scenario<span style="color: #339933;">::</span><span style="color: #004000;">Complete</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myExperiment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Easy, right? Rendering results looks like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Scenario<span style="color: #339933;">::</span><span style="color: #004000;">RenderXml</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myExperiment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The html output looks like this (data set is basically a bunch of randomized 50/50 data):</p>
<p><a href="http://www.tkstudios.com/wp-content/uploads/2010/10/Screen-shot-2010-10-06-at-5.54.40-PM.png"><img class="alignnone size-full wp-image-174" title="Screen shot 2010-10-06 at 5.54.40 PM" src="http://www.tkstudios.com/wp-content/uploads/2010/10/Screen-shot-2010-10-06-at-5.54.40-PM.png" alt="" width="378" height="284" /></a></p>
<p>If you specify &#8220;xml&#8221; for the translation, you&#8217;ll get something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Scenario<span style="color: #339933;">::</span><span style="color: #004000;">RenderXml</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myExperiment'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://www.tkstudios.com/wp-content/uploads/2010/10/Screen-shot-2010-10-06-at-6.42.25-PM.png"><img class="alignnone size-full wp-image-177" title="Screen shot 2010-10-06 at 6.42.25 PM" src="http://www.tkstudios.com/wp-content/uploads/2010/10/Screen-shot-2010-10-06-at-6.42.25-PM.png" alt="" width="513" height="200" /></a></p>
<p>Lots of thanks to <a href="http://20bits.com/">Jesse Farmer</a> for his <a title="Statistical Analysis and A/B Testing at 20Bits.com" href="http://20bits.com/articles/statistical-analysis-and-ab-testing/">incredibly useful article on statistical analysis and A/B testing</a>. That article saved me a lot of headaches in attempting to decode the wikipedia article on the underlying concept. Seriously, wiki is freakin&#8217; horrible when it comes to plain english explanations of mathematical concepts.</p>
<p>Any suggestions or feature requests while I&#8217;m in the documentation / tweaking phase?</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=phpScenario%2C+a+split+testing+library+http%3A%2F%2Fis.gd%2FllIF1k+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=phpScenario%2C+a+split+testing+library+http%3A%2F%2Fis.gd%2FllIF1k+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/&amp;title=phpScenario%2C+a+split+testing+library" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/10/06/phpscenario-a-split-testing-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP hashing performance experiment</title>
		<link>http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/</link>
		<comments>http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 05:26:52 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Listy]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=150</guid>
		<description><![CDATA[Today, in the never-ending quest to tweak server performance by a few milliseconds, I decided to do a bit of testing of various php hashing methods. I therefore wrote a quick script under php (5.2.11 currently, I need to update), which ran each test case 10,000 times to achieve a decent min/avg/max for each case, [...]]]></description>
			<content:encoded><![CDATA[<p>Today, in the never-ending quest to tweak server performance by a few milliseconds, I decided to do a bit of testing of various php hashing methods. I therefore wrote a quick script under php (5.2.11 currently, I need to update), which ran each test case 10,000 times to achieve a decent min/avg/max for each case, on strings of 10KB, 100KB, and 1,000KB in size.</p>
<p><span id="more-150"></span></p>
<p>The short version of the result is that the md5() function won across the board. The comments in the <a title="PHP: hash - Manual" href="http://us.php.net/manual/en/function.hash.php">php.net hash function documentation</a> seemed to indicate a performance increase in using hash(&#8216;md5&#8242;,$str), and an even better increase in hash(&#8216;md4&#8242;,$str). I found this to only partially be the case; While using the hash function, md4 is minutely faster than md5, the md5() function itself is considerably faster than either of these.</p>
<p>So, for any performance sensitive case, I would say md5() is by far the best choice.</p>
<p>Actual results of the test suite can be seen here:</p>
<p><a href="http://listy.us/list/view/153"><img src="http://www.listy.us/list/banner/153" alt="PHP Hash Performance by JSylvanus via Listy.us" /></a></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PHP+hashing+performance+experiment+http%3A%2F%2Fis.gd%2FHclqbV+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PHP+hashing+performance+experiment+http%3A%2F%2Fis.gd%2FHclqbV+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/&amp;title=PHP+hashing+performance+experiment" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/04/25/php-hashing-performance-experiment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listy.us &#8211; Now with Embedding!</title>
		<link>http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/</link>
		<comments>http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 22:08:00 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Listy]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=132</guid>
		<description><![CDATA[Today marks the first &#8220;Huge&#8221; update to Listy.us. It is now a paid service, handles uploaded files, and allows public lists to be embedded on any page. Like so: Tweet This Post Digg This Post Post to Reddit Stumble This Post]]></description>
			<content:encoded><![CDATA[<p>Today marks the first &#8220;Huge&#8221; update to Listy.us. It is now a paid service, handles uploaded files, and allows public lists to be embedded on any page. Like so:</p>
<p><span id="more-132"></span></p>
<p><script src="http://www.listy.us/list/embed/40" type="text/javascript"></script></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Listy.us+%E2%80%93+Now+with+Embedding%21+http%3A%2F%2Fis.gd%2Fn9g7Nh+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Listy.us+%E2%80%93+Now+with+Embedding%21+http%3A%2F%2Fis.gd%2Fn9g7Nh+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/&amp;title=Listy.us+%E2%80%93+Now+with+Embedding%21" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2010/03/23/listy-us-now-with-embedding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Email templating with layouts &amp; views</title>
		<link>http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/</link>
		<comments>http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 16:14:24 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Listy]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.tkstudios.com/?p=99</guid>
		<description><![CDATA[This is a solution that I came up with for sending out welcome emails, comment notifications, etc, with nice standardized HTML &#38; text layouts, using a few components of the Zend Framework. Basically you create a view (here called $renderer) and a layout ($layout), then render your views and layouts for both HTML and text [...]]]></description>
			<content:encoded><![CDATA[<p>This is a solution that I came up with for sending out welcome emails, comment notifications, etc, with nice standardized HTML &amp; text layouts, using a few components of the Zend Framework.</p>
<p>Basically you create a view (here called $renderer) and a layout ($layout), then render your views and layouts for both HTML and text versions. My file tree looks like this:</p>
<pre>application/
	emails/
		welcome.html.phtml
		welcome.text.phtml
		layouts/
			layout.html.phtml
			layout.text.phtml</pre>
<p>So, &#8216;welcome&#8217; would be your template name, with html and text versions. The layout is what you want wrapped around either version of every email you send out (header graphics, font settings, contact info, etc).</p>
<p><span id="more-99"></span></p>
<p>I keep all of my mail functions in one class, creating a new function for each email that needs to be sent out regularly in an automatic fashion. You could even use this for newsletters, but I prefer more robust environments like <a href="http://www.mailchimp.com/">MailChimp</a> or <a href="http://www.campaignmonitor.com/">CampaignMonitor</a> for that sort of thing.</p>
<p>This simple function handles all the rendering, file paths, etc. It just needs to be called with the proper template name, and an array of items to be passed to the view renderer.</p>
<p>Here&#8217;s the meat of it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * getMailContent
 * Renders mailer content in text and html and passes it back as an array('html'=&amp;gt;content,'text'=&amp;gt;content)
 *
 * @param string $templatename the name of the email template to use (APP/emails/[name].[format].phtml)
 * @param array $substitutions key=&amp;gt;value array of variables to pass to the view renderers
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getMailContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$templatename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$substitutions</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create a view renderer and set it to app_path/emails/</span>
    <span style="color: #000088;">$renderer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_View<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$renderer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setScriptPath<span style="color: #009900;">&#40;</span><span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/emails/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create a layout object and set it to app_path/emails/layouts</span>
    <span style="color: #000088;">$layout</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Layout<span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/emails/layouts/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setView<span style="color: #009900;">&#40;</span><span style="color: #000088;">$renderer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// this probably isn't even necessary</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// assign all substitutions (e.g. view variables) to the view renderer</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$substitutions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$sub</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$renderer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sub</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// output array        </span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// render text version of template &amp;amp; assign to output['text']</span>
    <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>content <span style="color: #339933;">=</span> <span style="color: #000088;">$renderer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>render<span style="color: #009900;">&#40;</span><span style="color: #000088;">$templatename</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.text.phtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setLayout<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'layout.text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// render html version of template &amp;amp; assign to output['html']</span>
    <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>content <span style="color: #339933;">=</span> <span style="color: #000088;">$renderer</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>render<span style="color: #009900;">&#40;</span><span style="color: #000088;">$templatename</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.html.phtml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setLayout<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'layout.html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$layout</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// all done, return output</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Nice and simple, huh? All you need to do is call it and then assign the output to your Zend_Mail object like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #000088;">$bodies</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getMailContent<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'new_comment'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'comment'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'comment_list'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$comment_list</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'comment_user'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$comment_user</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'list_owner'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$list_owner</span>
        <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setBodyHtml<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bodies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$mail</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setBodyText<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bodies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Your email template accesses the variables passed to it just as it would a normal view script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #009900;">&#91;</span>variable<span style="color: #009900;">&#93;</span></pre></div></div>

<p>Commentary / suggestions / etc welcome in comments.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=Zend+Framework%3A+Email+templating+with+layouts+%26+views+http%3A%2F%2Fis.gd%2FR6j2qY+%28%40tkstudios%29" title="Post to Twitter"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=Zend+Framework%3A+Email+templating+with+layouts+%26+views+http%3A%2F%2Fis.gd%2FR6j2qY+%28%40tkstudios%29" title="Post to Twitter">Tweet This Post</a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to Digg"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to Reddit"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/reddit/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to Reddit">Post to Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to StumbleUpon"><img class="nothumb" src="http://www.tkstudios.com/wp-content/plugins/tweet-this/icons/en/su/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/&amp;title=Zend+Framework%3A+Email+templating+with+layouts+%26+views" title="Post to StumbleUpon">Stumble This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.tkstudios.com/2009/12/02/zend-framework-email-templating-with-layouts-views/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

