<?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>does not validate &#187; Web Development</title>
	<atom:link href="http://doesnotvalidate.com/tag/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://doesnotvalidate.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 02 Jul 2010 06:31:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ODOPOD.COM = COMM ARTS WEB PICK OF THE DAY</title>
		<link>http://doesnotvalidate.com/2009/odopodcom-comm-arts-web-pick-of-the-day/</link>
		<comments>http://doesnotvalidate.com/2009/odopodcom-comm-arts-web-pick-of-the-day/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 19:23:18 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Awards]]></category>
		<category><![CDATA[Comm Arts]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[odopod]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=915</guid>
		<description><![CDATA[This is pretty exciting for me, and I think that after all of the hard work we put into that site the entire team at Odopod deserves a hearty congratulations&#8230; I&#8217;m really glad to see this site receiving the recognition that it deserves.


&#8220;Built to grow, on an easy-to-use content management system with tagged projects, and [...]]]></description>
			<content:encoded><![CDATA[<p>This is pretty exciting for me, and I think that after all of the hard work we put into that site the entire team at Odopod deserves a hearty congratulations&#8230; I&#8217;m really glad to see this site receiving the recognition that it deserves.</p>
<p><br/><a href="http://www.commarts.com/web-sites/odopod.html"><img src="http://doesnotvalidate.com/wp-content/uploads/odopod_commarts-460x345.jpg" alt="" title="odopod_commarts" width="460" height="345" class="alignnone size-medium wp-image-916" /></a></p>
<p><br/>
<div style='background-color: #cccccc; padding: 10px; font-style: italic;'>&#8220;Built to grow, on an easy-to-use content management system with tagged projects, and designed on a strict 16-pixel grid, this redesign is a clear showcase of the studio&#8217;s work.&#8221;</div>
<p><br/>Also &#8211; it&#8217;s nice to see the CMS getting some of the attention &#8211; although I&#8217;m biased &#8211; because I wrote this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/odopodcom-comm-arts-web-pick-of-the-day/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>THE RUMORS ARE TRUE</title>
		<link>http://doesnotvalidate.com/2009/the-rumors-are-true/</link>
		<comments>http://doesnotvalidate.com/2009/the-rumors-are-true/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 15:50:33 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Instrum3nt]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[odopod]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=878</guid>
		<description><![CDATA[
Yes, it&#8217;s true.  I&#8217;ve resigned from position as Senior Developer for odopod.  I really enjoyed my time there and I learned a great deal from both the partners as well as my colleagues &#8211; and I wish them all the best.
I just found myself increasingly drawn to my freelance work, as well as [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://doesnotvalidate.com/wp-content/uploads/odopod_card.jpg" alt="" title="odopod_card" width="460" height="345" class="alignnone size-full wp-image-551" /></p>
<p>Yes, it&#8217;s true.  I&#8217;ve resigned from position as Senior Developer for <a href='http://www.odopod.com' target="_blank">odopod</a>.  I really enjoyed my time there and I learned a great deal from both the partners as well as my colleagues &#8211; and I wish them all the best.</p>
<p><br/>I just found myself increasingly drawn to my freelance work, as well as my various personal projects &#8211; most of which sit unfinished (including this website).  I&#8217;m excited to have a chance to revive some old stuff, and introduce you to some of things <a href="http://www.faceofthecookie.com" target="_blank">Kiala</a> and I have been busy dreaming up these past few months.</p>
<p><br/>I&#8217;m very lucky to know a fantastic group of wonderfully successful people who have been able to provide me with steady work so far, but I&#8217;d always love to hear about new projects &#8211;  you can reach me @ <a href="mailto:dane@doesnotvalidate.com">dane@doesnotvalidate.com</a>.</p>
<p><br/>I&#8217;ll be updating this site with my most recent launches &#8211; like <a href="http://www.weareinstrument.com/#/work/dc-shoes-sales-kit" target="_blank">this project</a> that I worked on with the guys over at <a href="http://www.weareinstrument.com">Instrum3nt</a> for DC shoes, and <a href="http://www.odopod.com" target="_blank">the new Odopod site</a>.</p>
<p><br/>I&#8217;ve got some really exciting stuff happening in the next few weeks, and I&#8217;m very optimistic about the future.  Thanks to everyone who helped get me here.</p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/the-rumors-are-true/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Recent Launches</title>
		<link>http://doesnotvalidate.com/2009/recent-launches/</link>
		<comments>http://doesnotvalidate.com/2009/recent-launches/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 22:50:08 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=869</guid>
		<description><![CDATA[In the past few months I&#8217;ve launched a few projects &#8211; I&#8217;m planning an in-depth post about each of them, but for now here&#8217;s some images and links.

feliciaday.com

odopod.com
]]></description>
			<content:encoded><![CDATA[<p>In the past few months I&#8217;ve launched a few projects &#8211; I&#8217;m planning an in-depth post about each of them, but for now here&#8217;s some images and links.</p>
<p><br/><a href="http://www.feliciaday.com"><img src="http://doesnotvalidate.com/wp-content/uploads/picture-2-460x320.png" alt="" title="picture-2" width="460" height="320" class="alignnone size-medium wp-image-870" /></a><br />
<a href="http://www.feliciaday.com">feliciaday.com</a></p>
<p><br/><a href="http://odopod.com"><img src="http://doesnotvalidate.com/wp-content/uploads/125726543749a493d72f19f-414x600.png" alt="" title="odopod.com" width="414" height="600" class="alignnone size-medium wp-image-874" /></a><br />
<a href="http://www.odopod.com">odopod.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/recent-launches/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>RESIZING TRANSPARENT IMAGES WITH DJANGO + PIL</title>
		<link>http://doesnotvalidate.com/2009/resizing-transparent-images-with-django-pil/</link>
		<comments>http://doesnotvalidate.com/2009/resizing-transparent-images-with-django-pil/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 00:59:46 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[PIL]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=828</guid>
		<description><![CDATA[I can&#8217;t seem to get sorl thumbnail to play nice with transparent PNGs, it keeps adding weird black and grey backgrounds because it&#8217;s doesn&#8217;t maintain the alpha channel in it&#8217;s output.


Python&#8217;s PIL Module uses different versions of the Image.save() method depending on the format of the image being saved.  sorl thumbnail uses the following [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t seem to get <a href="http://code.google.com/p/sorl-thumbnail/" target="_blank">sorl thumbnail</a> to play nice with transparent PNGs, it keeps adding weird black and grey backgrounds because it&#8217;s doesn&#8217;t maintain the alpha channel in it&#8217;s output.</p>
<div style="text-align: center; padding: 10px;"><img style="margin-right: 60px;" src="http://comixapp.webfactional.com/assets/gfx/logotest1.png" alt="" /><br />
<img src="http://comixapp.webfactional.com/assets/gfx/logotest2.png" alt="" /></div>
<p><a href="http://www.pythonware.com/library/pil/handbook/format-png.htm">Python&#8217;s PIL Module</a> uses different versions of the <a href="http://www.pythonware.com/library/pil/handbook/image.htm" target="_blank">Image.save()</a> method depending on the format of the image being saved.  <a href="http://code.google.com/p/sorl-thumbnail/">sorl thumbnail</a> uses the following call when it creates the final image output:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">im.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">dest</span>, quality=<span style="color: #008000;">self</span>.<span style="color: black;">quality</span><span style="color: black;">&#41;</span></pre></div></div>

<p>This call utilizes a parameter call <em>quality</em> which, according to the documentation is only available on JPEGs.  Even changing the <em>THUMBNAIL_EXTENSION</em> in my settings.py file to &#8220;png&#8221; still didn&#8217;t make it maintain the alpha channel the way I had expected it to. <a href="http://code.google.com/p/sorl-thumbnail/issues/detail?id=56">Bug 56</a> is currently open for this issue at the <a href="http://code.google.com/p/sorl-thumbnail/" target="_blank">sorl thumbnail project home</a>.<br />
<br/><strong>The solution</strong><br />
<br/>I wanted to setup a way to pull the images off of the transparency resize them and then drop them on an opaque background of it&#8217;s own independent size.<br />
<br/>So the first thing I did was to load in an image via PIL:</p>
<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/nike-sb_logo.png" alt="" /></div>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">im = Image.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span></pre></div></div>

<p>So now that we&#8217;ve got our image we need to create the opaque background for it&#8230; right now we&#8217;ll just use a solid black one.  Use the following PIL method call to create a background at an identical size to the original image:</p>
<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest4.png" alt="" /></div>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bg = Image.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'RGBA'</span>, im.<span style="color: black;">size</span>, <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>At this point I&#8217;ve got two images, <strong>im</strong> the logo file and <strong>bg</strong> the opaque black background. Using the PIL <em>paste</em> method I can stick there two together.</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bg.<span style="color: black;">paste</span><span style="color: black;">&#40;</span>im<span style="color: black;">&#41;</span></pre></div></div>

<p>which gives us the following image:</p>
<div style="text-align: center; padding: 10px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest3.png" alt="" /></div>
<p>If you&#8217;re like me, you&#8217;re like &#8211; &#8220;WHAT THE HELL?!?! I just pasted a transparent PNG on a black background, why is it all white???&#8221;  The answer is because you didn&#8217;t tell Python to maintain the alpha channel when it pasted.<br />
<br/>The way that PIL deals with transparency when saving or pasting PNGs (that have a mode of &#8220;RGBA&#8221; or &#8220;P&#8221;) is to allow for a &#8220;transparency&#8221; parameter which is an integer from 0 &#8211; 255 which is sort of like a transparency tolerance for that image, and represents the &#8220;opaqueness&#8221; of the pixels to maintain transparency for.  Since this is different for every image what we need to do is just maintain the value of the PNG we&#8217;re working with.<br />
<br/><em>Note:</em> that if you paste an &#8220;RGBA&#8221; image (WE ARE!), the alpha band is ignored in a paste. You can work around this by using the same image as both source image and mask &#8211; like we have below.  More information at the <a href="http://www.pythonware.com/library/pil/handbook/image.htm" target="_blank">PIL Handbook</a><br />
<br/>Change the paste call to look like this:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bg.<span style="color: black;">paste</span><span style="color: black;">&#40;</span>im, <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>, im<span style="color: black;">&#41;</span></pre></div></div>

<p>which produces this:</p>
<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest5.png" alt="" /></div>
<p><span id="more-828"></span></p>
<p>This call has two additional parameters.  The first is is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)) for image we&#8217;re pasting in &#8211; for this we&#8217;re pasting it in at (0,0) &#8211; and the second is transparency value &#8211; which we&#8217;re just telling them use the the value from <strong>im</strong>.<br />
<br/>Although close this still isn&#8217;t quite right.  There are a bunch of extra transparent pixels which create the strips of blank vertical space on the top and bottom of the image&#8230; lets get rid of them.</p>
<p><br/>Add the following code right below the first image.open call like this:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">im = Image.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#convert to black and white</span>
invert = ImageChops.<span style="color: black;">invert</span><span style="color: black;">&#40;</span>im<span style="color: black;">&#41;</span>
bw = im.<span style="color: black;">convert</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;1&quot;</span><span style="color: black;">&#41;</span>
bw = bw.<span style="color: #008000;">filter</span><span style="color: black;">&#40;</span>ImageFilter.<span style="color: black;">MedianFilter</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># add a white bg and do a difference</span>
diffbg = Image.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;1&quot;</span>, im.<span style="color: black;">size</span>, <span style="color: #ff4500;">255</span><span style="color: black;">&#41;</span>
diff = ImageChops.<span style="color: black;">difference</span><span style="color: black;">&#40;</span>bw, diffbg<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#use the difference to create a bounding box</span>
bbox = diff.<span style="color: black;">getbbox</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#crop to that bounding box</span>
<span style="color: #ff7700;font-weight:bold;">if</span> bbox:
      im = im.<span style="color: black;">crop</span><span style="color: black;">&#40;</span>bbox<span style="color: black;">&#41;</span></pre></div></div>

<p>and we get just the non-transparent parts of the original:</p>
<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest6.png" alt="" /></div>
<p>The next step is to be able to dynamically control the color of the opaque background. In order to do this we need to accept a new parameter which should be a hex color value encased in quotes.  Change the line where you create the bg image to look like this (where <em>bgcolor</em> is the quoted hex color string):<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">bg = Image.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'RGBA'</span>, im.<span style="color: black;">size</span>, ImageColor.<span style="color: black;">getcolor</span><span style="color: black;">&#40;</span>bgcolor<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">'RGB'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>So if we passed the string &#8220;#FF0000&#8243; as bgcolor we get this:</p>
<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest7.png" alt="" /></div>
<p>Which is rad.  Now we want to pass in two different size values.  The first one is a maximum width / maximum height tuple for the logo.  Thsi value will be used to re-size the logo according to it&#8217;s aspect ratio to one of these maximum values.  The second value is also a tuple and is the absolute width and height of the background image.  Change your function to accept these 2 new parameters &#8211; I&#8217;m writing a custom Django Template tag which I will share at the end.</p>
<p><br/>Now change the line where you create the bg image, with these two lines of code where logo_width and logo_height are the integer values of your logo size tuple, and the same for bg_width and bg_height:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">im.<span style="color: black;">thumbnail</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>logo_width, logo_height<span style="color: black;">&#93;</span>, Image.<span style="color: black;">ANTIALIAS</span><span style="color: black;">&#41;</span>
bg = Image.<span style="color: #dc143c;">new</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'RGBA'</span>, <span style="color: black;">&#40;</span>bg_width,bg_height,<span style="color: black;">&#41;</span>, ImageColor.<span style="color: black;">getcolor</span><span style="color: black;">&#40;</span>bgcolor<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">'RGB'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<div style="text-align: center; padding: 20px;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest8.png" alt="" /></div>
<p>So now we&#8217;ve got independent sizes, lets center the logo in the background.  Replace the paste call from before with this code<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">image_width, image_height = im.<span style="color: black;">size</span>
xpos = <span style="color: black;">&#40;</span>bg_width/<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> - <span style="color: black;">&#40;</span>image_width/<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
ypos = <span style="color: black;">&#40;</span>bg_height/<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span> - <span style="color: black;">&#40;</span>image_height/<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
&nbsp;
bg.<span style="color: black;">paste</span><span style="color: black;">&#40;</span>im, <span style="color: black;">&#40;</span>xpos, ypos<span style="color: black;">&#41;</span>, im<span style="color: black;">&#41;</span></pre></div></div>

<p>so if we call the function like with the following parameters:</p>
<div style="margin: 20px 0; padding: 30px; background-color: #eeeeee;"><strong>background-color</strong> = &#8220;#FF0000&#8243;<br />
<strong>logo_size</strong> = [200x200]<br />
<strong>bg_size</strong> = [200x200]</div>
<p>produces this image:</p>
<div style="text-align: left; padding: 20px 0;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest9.png" alt="" /></div>
<p>and calling it with these parameters:</p>
<div style="margin: 20px 0; padding: 30px; background-color: #eeeeee;"><strong>background-color</strong> = &#8220;#FF0000&#8243;<br />
<strong>logo_size</strong> = [200x200]<br />
<strong>bg_size</strong> = [400x300]</div>
<p>produces this image:</p>
<div style="text-align: left; padding: 20px 0;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest10.png" alt="" /></div>
<p>and finally(!) calling the function with these parameters:</p>
<div style="margin: 20px 0; padding: 30px; background-color: #eeeeee;"><strong>background-color</strong> = &#8220;#000000&#8243;<br />
<strong>logo_size</strong> = [100x100]<br />
<strong>bg_size</strong> = [200x200]</div>
<p>produces this image:</p>
<div style="text-align: left; padding: 10px 0;"><img src="http://comixapp.webfactional.com/assets/gfx/logotest12.png" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/resizing-transparent-images-with-django-pil/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>NEW PERGO SITE LAUNCHES</title>
		<link>http://doesnotvalidate.com/2009/pergo-launches/</link>
		<comments>http://doesnotvalidate.com/2009/pergo-launches/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 20:44:10 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Struck]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=814</guid>
		<description><![CDATA[This is one of the first projects I worked on with STRUCK over a year ago for laminate floor manufacturer Pergo.
While we were busy building the site &#8211; Pergo was purchased by another company, and we were never sure if the site was going to see the light of day.
Well today it finally launched.
The site [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the first projects I worked on with <a href='http://www.struckcreative.com' target="_blank">STRUCK</a> over a year ago for laminate floor manufacturer Pergo.</p>
<p><br/>While we were busy building the site &#8211; Pergo was purchased by another company, and we were never sure if the site was going to see the light of day.</p>
<p><br/>Well today it finally launched.</p>
<p><br/>The site is written on this massive .NET e-commerce engine and I was in charge of all of the backend programming work, as well as managing the .NET + AJAX + Flash integration points.</p>
<p><br/><strong>URL:</strong> <a href='http://na.pergo.com/'>http://na.pergo.com/</a></p>
<p><br/><a href="http://doesnotvalidate.com/wp-content/uploads/pergo1.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/pergo1-459x288.jpg" alt="" title="pergo1" width="459" height="288" class="alignnone size-medium wp-image-815" /></a></p>
<p><br/><a href="http://doesnotvalidate.com/wp-content/uploads/pergo2.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/pergo2-460x268.jpg" alt="" title="pergo2" width="460" height="268" class="alignnone size-medium wp-image-816" /></a></p>
<p><br/><a href="http://doesnotvalidate.com/wp-content/uploads/pergo2b.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/pergo2b-460x268.jpg" alt="" title="pergo2b" width="460" height="268" class="alignnone size-medium wp-image-817" /></a></p>
<p><br/><a href="http://doesnotvalidate.com/wp-content/uploads/pergo3.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/pergo3-460x344.jpg" alt="" title="pergo3" width="460" height="344" class="alignnone size-medium wp-image-818" /></a></p>
<p><br/><a href="http://doesnotvalidate.com/wp-content/uploads/pergo4.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/pergo4-460x317.jpg" alt="" title="pergo4" width="460" height="317" class="alignnone size-medium wp-image-819" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/pergo-launches/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TIMBERLINE LODGE WEBSITE</title>
		<link>http://doesnotvalidate.com/2009/timberline-lodge-website/</link>
		<comments>http://doesnotvalidate.com/2009/timberline-lodge-website/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 18:13:37 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[dane@doesnotvalidate.com]]></category>
		<category><![CDATA[Nemo]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[Timberline]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=790</guid>
		<description><![CDATA[

URL: http://www.timberlinelodge.com
Agency: Nemo
Role: Lead Developer
Technology: PHP / Wordpress
Featured in the Wordpress Showcase
]]></description>
			<content:encoded><![CDATA[<p><a href="http://doesnotvalidate.com/wp-content/uploads/tline_home2.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/tline_home2-460x504.jpg" alt="" title="tline_home2" width="460" height="504" class="alignnone size-medium wp-image-671" /></a></p>
<p><a href="http://doesnotvalidate.com/wp-content/uploads/tline_sub.jpg"><img src="http://doesnotvalidate.com/wp-content/uploads/tline_sub-367x600.jpg" alt="" title="tline_sub" width="367" height="600" class="alignnone size-medium wp-image-672" /></a></p>
<p><br/><strong>URL:</strong> <a href='http://www.timberlinelodge.com' target='_blank'>http://www.timberlinelodge.com</a><br />
<strong>Agency:</strong> <a href='http://www.nemohq.com' target='_blank'>Nemo</a><br />
<strong>Role:</strong> Lead Developer<br />
<strong>Technology:</strong> PHP / <a href='http://www.wordpress.org'>Wordpress</a></p>
<p><br/>Featured in the <a href='http://wordpress.org/showcase/timberline-lodge/' target='_blank'>Wordpress Showcase</a></p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/timberline-lodge-website/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WORDPRESS &#8211; EASILY LOOP THROUGH PAGE CHILDREN</title>
		<link>http://doesnotvalidate.com/2009/wordpress-easily-loop-thru-page-children/</link>
		<comments>http://doesnotvalidate.com/2009/wordpress-easily-loop-thru-page-children/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 22:20:12 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[dane@doesnotvalidate.com]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[Wordpress Code]]></category>
		<category><![CDATA[Wordpress Theming]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=773</guid>
		<description><![CDATA[The following code will let you create a custom &#8220;Wordpress Loop&#8221; that contains the post objects of the children of the current page.
Just drop this code in your theme file:


&#60;?php
    $project_list = get_posts&#40;'numberposts=5&#38;order=ASC&#38;orderby=menu_order&#38;post_type=page&#38;post_parent='.$post-&#62;ID&#41;;
&#160;
    foreach&#40;$project_list as $post&#41;:
    setup_postdata&#40;$post&#41;;
?&#62;
    &#60;div class=&#34;post&#34; id=&#34;post-&#60;?php the_ID&#40;&#41;; ?&#62;&#34;&#62;
  [...]]]></description>
			<content:encoded><![CDATA[<p>The following code will let you create a custom &#8220;Wordpress Loop&#8221; that contains the post objects of the children of the current page.</p>
<p><br/>Just drop this code in your theme file:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000088;">$project_list</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=5&amp;order=ASC&amp;orderby=menu_order&amp;post_type=page&amp;post_parent='</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$project_list</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
    setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;div class=&quot;post&quot; id=&quot;post-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
    &lt;/div&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
    <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/wordpress-easily-loop-thru-page-children/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using jQuery to Build a Better Flash Fly-Down Nav</title>
		<link>http://doesnotvalidate.com/2009/using-jquery-to-build-a-better-flash-fly-down-navigation/</link>
		<comments>http://doesnotvalidate.com/2009/using-jquery-to-build-a-better-flash-fly-down-navigation/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 18:10:57 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[dane@doesnotvalidate.com]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[odopod]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=766</guid>
		<description><![CDATA[It seems simple, but one of the most troublesome tasks is to get a Flash fly-down (or drop-down) menu to reliably collapse when it sits over non-Flash content.  Some browsers (IE) have trouble recognizing the  change of control from the Flash Player application instance to the browser.  For that reason Flash won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>It seems simple, but one of the most troublesome tasks is to get a Flash fly-down (or drop-down) menu to reliably collapse when it sits over non-Flash content.  Some browsers (IE) have trouble recognizing the  change of control from the Flash Player application instance to the browser.  For that reason Flash won&#8217;t always read when the mouse has moved outside the bounds of the Flash Player&#8230; worse still &#8211; it just receives no notification at all, which means that if you&#8217;re relying on Flash to read when the mouse has moved outside the bounds of the navigation &#8211; you&#8217;re out of luck.  </p>
<p><br/>Over the years I&#8217;ve come up with many tricks to help deal with this &#8211; some more effective than others.  Today I found the best solution to date.  It&#8217;s not 100% effective, but it&#8217;s much better than any of the other options that I used.</p>
<p><br/>I decided to try using the <a href='http://www.jquery.com'>jQuery</a> <a href='http://docs.jquery.com/Events/hover#overout'>hover method</a> to detect when the mouse leaves the Flash&#8217;s containing DIV element in the DOM.</p>
<p><br/>The AJAX code looked something like this:</p>
<p><br/></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'document'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#flashNavReplace'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
	    <span style="color: #006600; font-style: italic;">//rollover functionality here</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            getFlashMovie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;flashNavReplace&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">jsCloseNavigation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getFlashMovie<span style="color: #009900;">&#40;</span>movieName<span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> isIE <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">appName</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>isIE<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> window<span style="color: #009900;">&#91;</span>movieName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> document<span style="color: #009900;">&#91;</span>movieName<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>and then the Flash side uses some code like this:</p>
<p><br/></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">/**************************************************************************
* 
* CONSTRUCTOR
* 
**************************************************************************/</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TopNavigation<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">//setup the JS callback</span>
    ExternalInterface.<span style="color: #006600;">addCallback</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;jsCloseNavigation&quot;</span>, jsClose<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> jsClose<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    Logger.<span style="color: #0066CC;">log</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;CALLED FROM JS&quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">//close the nav</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p><br/>This works for me pretty much all of the time&#8230; I can break it if I really try, but it works great for normal usage.</p>
]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/using-jquery-to-build-a-better-flash-fly-down-navigation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Activate URLs and Twitter Profile Links with PHP</title>
		<link>http://doesnotvalidate.com/2009/activate-urls-and-twitter-profile-links-with-php/</link>
		<comments>http://doesnotvalidate.com/2009/activate-urls-and-twitter-profile-links-with-php/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 15:22:48 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[dane@doesnotvalidate.com]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=741</guid>
		<description><![CDATA[
In a current project I&#8217;m reading in a user&#8217;s Twitter feed and displaying it on the hompage of their Wordpress blog.  I know that there are a thousand plug-ins that exist to do this exact thing, but I wanted to write my own. 
Using the official Twitter API the contents of the individual were [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://doesnotvalidate.com/wp-content/uploads/twitter.jpg" alt="" title="Twitter" width="460" height="250" class="alignnone size-full wp-image-753" /></p>
<p><br/>In a current project I&#8217;m reading in a user&#8217;s Twitter feed and displaying it on the hompage of their Wordpress blog.  I know that there are a thousand plug-ins that exist to do this exact thing, but I wanted to write my own. </p>
<p><br/>Using the official Twitter API the contents of the individual were returned as plain text, meaning that all HTML links were totally dead. I wanted a way to automatically add the HTML to enable URL&#8217;s as well as twitter &#8220;@&#8221; profile links. I found some regular expressions and with some tweaking came up with these 2 functions.</p>
<p><br/>To activate the URLs in block of text pass it to the following function:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> activateURLS<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@&quot;</span><span style="color: #339933;">,</span> 
        <span style="color: #0000ff;">&quot;&lt;a href=&quot;</span>$<span style="color: #cc66cc;">1</span><span style="color: #0000ff;">&quot; target=&quot;</span>_blank<span style="color: #0000ff;">&quot;&gt;<span style="color: #006699; font-weight: bold;">$1</span>&lt;/a&gt;&quot;</span><span style="color: #339933;">,</span> 
        <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/>To activate Twitter @ profile links using the following PHP block:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> activateTwitterProfiles<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/@([^ ,.!#$%^&amp;]+)/&quot;</span><span style="color: #339933;">,</span> 
        <span style="color: #0000ff;">&quot;&lt;a href=&quot;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//twitter.com/$1&quot; target=&quot;_blank&quot;&gt;@$1&lt;/a&gt;&quot;, </span>
        <span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/>They&#8217;re super easy to use, just call them like this:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">activateTwitterProfiles<span style="color: #009900;">&#40;</span>activateLinks<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/activate-urls-and-twitter-profile-links-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wordpress: Get Posts By Custom Field Values</title>
		<link>http://doesnotvalidate.com/2009/wordpress-get-posts-by-custom-fields/</link>
		<comments>http://doesnotvalidate.com/2009/wordpress-get-posts-by-custom-fields/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 00:07:42 +0000</pubDate>
		<dc:creator>Dane</dc:creator>
				<category><![CDATA[left]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[Dane Hesseldahl]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://doesnotvalidate.com/?p=726</guid>
		<description><![CDATA[Thought Wordpress nerds might find this useful, a function to retrieve a list of posts by passing in a custom filed key=>value pair, with an optional count parameter.
Just drop this in your &#8220;functions.php&#8221;:


function getPostsByMeta&#40;$key, $value, $count = -1&#41;
&#123;
    global $wpdb;
&#160;
    $sql = &#34;SELECT DISTINCT wp_posts.post_title,
    wp_posts.ID [...]]]></description>
			<content:encoded><![CDATA[<p>Thought Wordpress nerds might find this useful, a function to retrieve a list of posts by passing in a custom filed key=>value pair, with an optional count parameter.<br />
<br/>Just drop this in your &#8220;functions.php&#8221;:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getPostsByMeta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT DISTINCT wp_posts.post_title,
    wp_posts.ID FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>,
    <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span> 
    WHERE <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID = <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.post_id 
    AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_status = 'publish' 
    AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_key = '<span style="color: #006699; font-weight: bold;">$key</span>' 
    AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;postmeta</span>.meta_value = '<span style="color: #006699; font-weight: bold;">$value</span>' 
    ORDER BY post_date DESC&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot; LIMIT &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$count</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and then you can use it like this:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">$news_home = getPostsByMeta('_tb_post_section', 'News', 3); 
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$news_home</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$news</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;!-- OUTPUT TEMPLATED HTML --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://doesnotvalidate.com/2009/wordpress-get-posts-by-custom-fields/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
