<?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>teddy-risation</title>
	<atom:link href="http://teddy-o-ted.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://teddy-o-ted.com</link>
	<description>Design of a minimalist, content of a maximalist</description>
	<lastBuildDate>Thu, 26 Aug 2010 07:32:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Nicholas Hance McElroy Photography</title>
		<link>http://teddy-o-ted.com/blog/2010/08/26/nicholas-hance-mcelroy-photography/</link>
		<comments>http://teddy-o-ted.com/blog/2010/08/26/nicholas-hance-mcelroy-photography/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 07:26:37 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Bookmarked]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=10515</guid>
		<description><![CDATA[Nicholas Hance McElroy (aka Nick Hance) is a photographer living in the American West. You can find his works on <a title="Nick Hance on Flickr" href="http://www.flickr.com/photos/lawns/">Flickr</a>, as well as on his <a title="Nick Hance's site" href="http://www.nhmcelroy.com/">site</a>.

I adore his work because they have a very subtle vintage look to them. The landscapes are stunning, the portraits are beautiful and inanimate objects are breathing life through his photos.]]></description>
			<content:encoded><![CDATA[<div id="attachment_10516" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/08/nickhance01.jpg" rel="lightbox[10515]"><img class="size-medium wp-image-10516" title="Untitled. By Nick Hance" src="http://teddy-o-ted.com/wp-content/uploads/2010/08/nickhance01-600x439.jpg" alt="Untitled. By Nick Hance" width="600" height="439" /></a><p class="wp-caption-text">Untitled. By Nick Hance</p></div>
<p>Nicholas Hance McElroy (aka Nick Hance) is a photographer living in the American West. You can find his works on <a title="Nick Hance on Flickr" href="http://www.flickr.com/photos/lawns/">Flickr</a>, as well as on his <a title="Nick Hance's site" href="http://www.nhmcelroy.com/">site</a>.</p>
<p>I adore his work because they have a very subtle vintage look to them. The landscapes are stunning, the portraits are beautiful and inanimate objects are breathing life through his photos.</p>
<h3  class="related_post_title">Random</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2005/02/04/fbi-wasted-millions-on-virtual-case-file/" title="FBI wasted millions on &#8216;Virtual Case File&#8217;">FBI wasted millions on &#8216;Virtual Case File&#8217;</a></li><li><a href="http://teddy-o-ted.com/blog/2005/02/18/stupid-people-with-stupid-surfing-habits/" title="Stupid People With Stupid Surfing Habits">Stupid People With Stupid Surfing Habits</a></li><li><a href="http://teddy-o-ted.com/blog/2005/07/16/stubborn-little-brother/" title="Stubborn Little Brother">Stubborn Little Brother</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/08/26/nicholas-hance-mcelroy-photography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Money is the root of all evil&#8230; thoughts</title>
		<link>http://teddy-o-ted.com/blog/2010/08/25/money-is-the-root-of-all-evil-thoughts/</link>
		<comments>http://teddy-o-ted.com/blog/2010/08/25/money-is-the-root-of-all-evil-thoughts/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 17:14:30 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Food for Thought]]></category>
		<category><![CDATA[Academics]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[University]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=10512</guid>
		<description><![CDATA[So it turns out that I might not be going for an exchange program next January afterall. It took me awhile to acknowledge the fact, but I felt that it is terribly unfair for me to unload the entire financial burden onto my parent&#8217;s shoulder when studying in my university (NTU) during that period is [...]]]></description>
			<content:encoded><![CDATA[<p>So it turns out that I might not be going for an exchange program next January afterall.</p>
<p>It took me awhile to acknowledge the fact, but I felt that it is terribly unfair for me to unload the entire financial burden onto my parent&#8217;s shoulder when studying in my university (NTU) during that period is just as good as going to Sweden instead.</p>
<p>Sweden is good, sans the whole Julian Assange rape smearing case which Sterling succinctly pointed out to me on Twitter earlier today. The weather there is nice. The people there are very hospitable, welcoming and eco-friendly. Their meatballs are awesome. If all these don&#8217;t cut it, at least I know that it is where my favourite furniture chain IKEA was conceived. Okay, but I still hated IKEA for <a href="http://www.nowpublic.com/style/ikea-font-futura-verdana-what-changed-and-why" title="IKEA Font: Futura to Verdana, What Changed and Why?">using Verdana</a>.</p>
<p>I just returned from a one-day trip to and from Singapore to attend this talk about the exchange program and how we should navigate ourselves around those miles and miles of crazy bureaucracy red tape. I&#8217;m not going to moan, whine, whimper, cry baby about this wasted trip &#8211; I did get lots of information about the lovely country from a senior who had just returned from the very country I&#8217;ve been yearning to travel, live and study in, and learning more about the exchange program isn&#8217;t exactly something half bad.</p>
<p>The gist of the problem lies with the money. I don&#8217;t live in a upper-middle class, or a high class family. We don&#8217;t rake in money by the five or more figures monthly. My dad works as a project manager cum architect in a small medium enterprise, while my mom spends most of her days cooping in the tuition class handling kids that are so wild I thought nobody could ever get hold of them. Well, at least my mom did.</p>
<p>The entire exchange program will set me back by around S$10,000 to S$12,000, which is a lot. Probably a few times of our household income. My brother still has one more year to see before he finishes college, and God knows what he&#8217;ll do after that. S$10,000 might not sound a lot to you (it converts to around US$7,350), but it does mean a lot to a small family like mine.</p>
<p>Because of my academic achievements, I&#8217;ve been studying in Singapore, a country 400km south of my hometown, for the past 8.5 (and counting) years, relying solely on scholarships. The first 6 years I was on a government scholarship since graduating from elementary school, and for the next 2.5 I&#8217;m on a university-sponsored scholarship that pays for the rest of my tuition fees.</p>
<p>For a very tiny instant moment I felt that all these should count in my advantage because I&#8217;ve been saving tons of money for my parents &#8211; instead of channeling that money into funding my education, they have stashed them in all forms of investments, bank accounts (probably not a good idea), fixed deposits and anything that has to do with money without actually spending them.</p>
<p>Immediately my conscience came riding on this moral high horse and giving me a mental lecture about how dare I conjunture such a thought &#8211; saving my parents that much money doesn&#8217;t mean I&#8217;m entitled to spend them right now, even if that S$10,000 is going to be just a fraction of it. Who do I think I am, for being so selfish, to think that I should make my parents pay for my exchange program that is so incredibly expensive?</p>
<p>An instant sense of shame overcame myself. I couldn&#8217;t possibly think what my parents have been through after I told them that I have set my eyes on Sweden for the exchange programs. Their jaws were left somewhat agape when I broke the news about the overall costs, and I hate myself even the more now for allowing such a lapse of judgement to take place.</p>
<p>So I make sure that I got it clear today &#8211; I told them that they shouldn&#8217;t care about what I would think. Even if I would feel disappointed and probably be all sad panda when I couldn&#8217;t go to Sweden, I know that the lump sum of money could be better spent elsewhere. I&#8217;ll give them the choice to choose &#8211; and I very well know that it doesn&#8217;t lie with me.</p>
<p>I&#8217;ll still be matching my courses for the exchange program, but that doesn&#8217;t meant that I&#8217;m getting my hopes high for parental approval. I&#8217;m not bitter about this, and in fact I feel a little embarrassed that I have been engaged in this endless soliloquy with myself throughout the entire day.</p>
<p>Wise up, Terry.</p>
<p>p/s: For once, I&#8217;m ecstatic about me being so honest with myself.</p>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2009/11/18/on-comes-the-panic-light/" title="On comes the panic light">On comes the panic light</a></li><li><a href="http://teddy-o-ted.com/blog/2009/10/05/if-ten-million-fireflies-lit-up-the-world-as-i-fell-asleep/" title="If ten million fireflies lit up the world as I fell asleep">If ten million fireflies lit up the world as I fell asleep</a></li><li><a href="http://teddy-o-ted.com/blog/2009/04/08/some-people-wait-a-lifetime/" title="Some people wait a lifetime">Some people wait a lifetime</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/08/25/money-is-the-root-of-all-evil-thoughts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Better Form Usability with jQuery</title>
		<link>http://teddy-o-ted.com/blog/2010/08/08/better-form-usability-with-jquery/</link>
		<comments>http://teddy-o-ted.com/blog/2010/08/08/better-form-usability-with-jquery/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 19:03:40 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=10488</guid>
		<description><![CDATA[The &#60;label&#62; tag is a rather commonly omitted element in HTML forms. Although the tag does not render text in it differently from those outside the tag, it provides a usability improvement for mouse users by duplicating common GUI features. More importantly, it couples an input element with a label for users of speech browsers. [...]]]></description>
			<content:encoded><![CDATA[<p>The <code>&lt;label&gt;</code> tag is a rather commonly omitted element in HTML forms. Although the tag does not render text in it differently from those outside the tag, it provides a usability improvement for mouse users by duplicating common GUI features. More importantly, it couples an input element with a label for users of speech browsers.</p>
<p>The <code>&lt;label&gt;</code> tag can be used as is, but it has an extremely useful attribute &#8211; the <code>for</code> attribute. This attribute allows one to associate a form control with the element, when its value matches the ID of the form control. Here&#8217;s a sample of a usable, but not the best, form, without the use of the <code>&lt;label&gt;</code> tag:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form-1&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;author&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Email<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>URL<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Comment<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comment&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>When we add the the <code>for</code> attribute to the <code>&lt;label&gt;</code> element and assign it a value that is identical to the <code>id</code> attribute of the form control, we will improve the usability of the form. For visually-impaired users, the speech browsers are able to draw a link between a form control and it’s label, which will provide important information and even instructions in filling up the form. For those using visual browsers are, in turn, able to focus on a specific form control when its associated label is clicked on.</p>
<p>Here is the improved form:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form-1&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;author&quot;</span>&gt;</span>Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;author&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;author&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span>&gt;</span>Email<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span>&gt;</span>URL<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comment&quot;</span>&gt;</span>Comment<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comment&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comment&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<h2>What does jQuery have to do with this?</h2>
<p>You must be puzzled &#8211; afterall, what you need to do so far is to manually inject the <code>for</code> and <code>id</code> attributes into the <code>&lt;label&gt;</code> and <code>&lt;input&gt;</code> elements respectively. In fact, I was actually doing these manual changes to my theme files and other web-based projects because it will only take me at most a few minutes&#8217; worth of time.</p>
<p>However, I recently faced a problem that I felt using jQuery as a workaround wasn&#8217;t a bad idea afterall. Many people would advice against using JavaScript in cases like this for two reasons: some users, albeit a minority, don&#8217;t allow JavaScript to run on their browser; and on a related note, with the possibility that JavaScript being disabled in mind, we shouldn&#8217;t use it to implement essential features.</p>
<p>The problem was that I was working with some WP plugins that generates HTML forms dynamically and on the fly. Although some would dive into the realm of PHP and make the necessary changes such that the generated forms are more user-friendly, I would prefer using the jQuery way, which is easier and does not require muddling with the source code of the plugin files.</p>
<p>There are a few steps that we have to do:</p>
<ol>
<li>Retrieve the value of the <code>name</code> attribute of the <code>&lt;input&gt;</code> element.</li>
<li>Assign a unique ID to the <code>&lt;input&gt;</code> element.</li>
<li>Assign the same value (the unique ID) to the <code>for</code> attribute of <code>&lt;label&gt;</code>.</li>
</ol>
<p>For those copy-happy folks, here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<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;">&quot;#form-1 &gt; p&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> input_id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> input_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;for&quot;</span><span style="color: #339933;">,</span> input_id<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></pre></div></div>

<h2>Dissecting the code</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#form-1 &gt; p&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>This line searches the document for the paragraphy element, <code>&lt;p&gt;</code> that is a direct descendant of an element with an ID of <code>#form-1</code>. The <code>.each()</code> function makes sure that we look the subsequent function across all elements that satisfy the selection criteria. The <code>count</code> variable is declared and it will be used in each iteration.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> input_id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This line defines the variable <code>input_id</code>, and assigns it the value of that is the that of the <code>name</code> attribute of the <code>&lt;input&gt;</code> element combined with a unique number. The number is increased by a value of 1 after each iteration of the loop so that we will generate unique IDs, even in face of an unprobably scenario that two input fields on the same page share the same value of the <code>name</code> attribute.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span> input_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;for&quot;</span><span style="color: #339933;">,</span> input_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>These two lines do the same thing &#8211; the finds the <code>&lt;input&gt;</code> and <code>&lt;label&gt;</code> elements in the same parent element, and assigns the generated value to the <code>id</code> of the former and <code>for</code> attribute of the latter.</p>
<h2>Note</h2>
<p>Note that this technique only works if each <code>&lt;label&gt;</code> and <code>&lt;input&gt;</code> pair is located in the same parent element, and each parent element has only one pair of label and input field in it. Of course, there is a solution for those forms that do not wrap each pair in a parent element, but I will not dwell into it.</p>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2010/05/22/wp-widget-load-posts-in-a-category/" title="WP Widget: Load posts in a category">WP Widget: Load posts in a category</a></li><li><a href="http://teddy-o-ted.com/blog/2009/09/10/35-stylish-and-modern-wordpress-plugins-using-jquery-ui/" title="35 Stylish And Modern Wordpress Plugins Using jQuery UI">35 Stylish And Modern Wordpress Plugins Using jQuery UI</a></li><li><a href="http://teddy-o-ted.com/blog/2009/05/24/wp-theme-teddy-risation-theta/" title="WP theme: teddy-risation Theta">WP theme: teddy-risation Theta</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/08/08/better-form-usability-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Inception and Gotham</title>
		<link>http://teddy-o-ted.com/blog/2010/07/27/inception-and-gotham/</link>
		<comments>http://teddy-o-ted.com/blog/2010/07/27/inception-and-gotham/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 08:39:59 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Movies]]></category>
		<category><![CDATA[Film]]></category>
		<category><![CDATA[Gotham]]></category>
		<category><![CDATA[Typeface]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=10479</guid>
		<description><![CDATA[I have watched Inception last weekend and I have to say it&#8217;s a really mind-blowing film. People are saying that Chris Nolan invaded everyone&#8217;s dream and planted the idea that the film is great *laughs* but that&#8217;s not the main point. What really caught my attention was the choice of typeface used. It is immediately [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_10480" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/inception-gotham01.png" rel="lightbox[10479]"><img class="size-medium wp-image-10480" title="Gotham, a typeface used in the film, Inception" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/inception-gotham01-600x266.png" alt="Gotham, a typeface used in the film, Inception" width="600" height="266" /></a><p class="wp-caption-text">Gotham, a typeface used in the film, Inception</p></div>
<p>I have watched Inception last weekend and I have to say it&#8217;s a really mind-blowing film. People are saying that Chris Nolan invaded everyone&#8217;s dream and planted the idea that the film is great *laughs* but that&#8217;s not the main point.</p>
<p>What really caught my attention was the choice of typeface used. It is immediately obvious that they did not use <a title="Trajan (Typeface)" href="http://en.wikipedia.org/wiki/Trajan_(typeface)"><em>Trajan</em></a> for their movie posters, something I applaud. <em>Trajan</em> is an overused typeface &#8211; and here&#8217;s a non-exhaustive list of popular films in the past that have used <em>Trajan</em> in their posters (in fact, there are <a title="Trajan Film Poster" href="http://www.flickr.com/groups/trajanfilmposter/pool/">153</a> and counting posters):</p>
<ul>
<li>The Final Destination (2009)</li>
<li>One Missed Call (2008)</li>
<li>Sex and the City (2008)</li>
<li>Bridge to Terabithia (2007)</li>
<li>I Am Legend (2007)</li>
<li>Star Dust (2007)</li>
<li>Final Destination 3 (2006)</li>
<li>Requiem (2006)</li>
<li>The Core (2003)</li>
<li>A Beautiful Mind (2001)</li>
<li>The Mummy Returns (2001)</li>
<li>The Perfect Storm (2000)</li>
<li>The Mummy (1999)</li>
<li>City of Angels (1998)</li>
<li>Deep Rising (1998)</li>
<li>Titanic (1997)</li>
</ul>
<div id="attachment_10484" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/fontyfridayv2_gotham.png" rel="lightbox[10479]"><img class="size-medium wp-image-10484" title="Gotham Typeface" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/fontyfridayv2_gotham-600x375.png" alt="Gotham Typeface" width="600" height="375" /></a><p class="wp-caption-text">Gotham Typeface</p></div>
<p>They chose <a title="Gotham (Typeface)" href="http://en.wikipedia.org/wiki/Gotham_(typeface)"><em>Gotham</em></a> instead. It is a geometric typeface designed by Tobias Frere-Jones and Jesse Ragan. Familiar typeface, isn’t it? That’s because <em>Gotham</em> has appeared in:</p>
<ul>
<li>Obama’s presidential campaign posters</li>
<li>Movie posters of Moon (by the way I recommend you watch this film)</li>
<li>Branding for Discovery Channel, USA Network, Astro and more.</li>
<li>Chicago’s 2016 Summer Olympics bid.</li>
</ul>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2010/03/26/fonty-friday-edifice/" title="Fonty Friday: Edifice">Fonty Friday: Edifice</a></li><li><a href="http://teddy-o-ted.com/blog/2009/10/15/leave-me-a-short-film/" title="Leave Me, a short film">Leave Me, a short film</a></li><li><a href="http://teddy-o-ted.com/blog/2009/09/25/prewedding-film-imagine/" title="Prewedding film &#8220;IMAGINE&#8221;">Prewedding film &#8220;IMAGINE&#8221;</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/07/27/inception-and-gotham/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Launching two new sites</title>
		<link>http://teddy-o-ted.com/blog/2010/07/24/launching-two-new-sites/</link>
		<comments>http://teddy-o-ted.com/blog/2010/07/24/launching-two-new-sites/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 01:52:00 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=10470</guid>
		<description><![CDATA[After the past few weeks, I was busy with the work I&#8217;m getting from my internship position with a local design firm, but I still managed to dedicate enough free time to two sites I was launching. They&#8217;re not really community-powered sites, so there&#8217;s nothing hyper about it *laughs* Tweet Archive (link) In light of [...]]]></description>
			<content:encoded><![CDATA[<p>After the past few weeks, I was busy with the work I&#8217;m getting from my internship position with a local design firm, but I still managed to dedicate enough free time to two sites I was launching. They&#8217;re not really community-powered sites, so there&#8217;s nothing hyper about it *laughs*</p>
<h2>Tweet Archive (<a title="teddy-risation Twitter Archive" href="http://tweets.teddy-o-ted.com/">link</a>)</h2>
<div id="attachment_10471" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/tweetarchive01.png" rel="lightbox[10470]"><img class="size-medium wp-image-10471" title="Tweet Archive" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/tweetarchive01-600x436.png" alt="Tweet Archive" width="600" height="436" /></a><p class="wp-caption-text">Tweet Archive</p></div>
<p>In light of the recent instability of Twitter, especially over the one-month span of the World Cup, I have decided that backing up my tweets on a remote server will be a wise choice. Not only does the remote server helps to archive all the tweets that I have been posting since then, it also creates a searchable tweet archive. Don&#8217;t you find it frustrating that even you yourself can&#8217;t comb through your own tweets on Twitter web interface?</p>
<p>However, I was only able to retrieve down to the last 3,200 tweets (dating back to August 2009). The 3,200 cap was placed on Twitter API to prevent it from being overloaded with requests&#8230; which means I&#8217;ve lost around 5000+ of my older tweets, but it&#8217;s okay.</p>
<p>I got the idea after <a title="Jeff at PerishablePress" href="http://perishablepress.com/">Jeff</a> (<a title="Jeff on Twitter" href="http://twitter.com/perishable">@perishable</a>) wrote about backing up his tweets during Twitter&#8217;s wobbly period. And he has <a title="Perishable Tweet Archive by Jeff Starr" href="http://perishablepress.com/tweets/">got his tweets backed up</a> already, too.</p>
<div id="attachment_10472" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/tweetarchive02.png" rel="lightbox[10470]"><img class="size-full wp-image-10472" title="Jeff's tweet about archiving his tweets" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/tweetarchive02.png" alt="Jeff's tweet about archiving his tweets" width="600" height="280" /></a><p class="wp-caption-text">Jeff&#39;s tweet about archiving his tweets</p></div>
<p>What I did wasn&#8217;t exactly quite rocket science (maybe except for the regex part):</p>
<ol>
<li>Upgrade my site to WP3.0, and <a title="How to enable Multi-Site option in WordPress 3.0" href="http://www.wpbeginner.com/wp-tutorials/how-to-enable-multi-site-option-in-wordpress-3-0/">activate the WP multisite feature</a>. If you&#8217;re done with this step, everything will be a lot easier. <strong>Note: Please check with your host if they support wildcard DNS, i.e. *.domain.tld.</strong> If such a feature is not offered, it&#8217;s not all kaboom. Simply create a new WP installation in the subdomain&#8217;s root directory.</li>
<li>Install a new child blog pointing to <a title="teddy-risation Tweet Archive" href="http://tweets.teddy-o-ted.com">http://tweets.teddy-o-ted.com</a></li>
<li>Download your Twitter archive &#8211; I recommend <a title="TweetBackup" href="http://tweetbackup.com/">TweetBackup</a>. Export the latest 3,200 tweets (or less) as an RSS feed and download it. Try to refrain from tweeting between downloading your Twitter archive and the completion of the set up &#8211; you wouldn&#8217;t want any tweets to fall through.</li>
<li>Import your Twitter archive to your WP installation.<strong> If your server is slow, the import script might exceed the 30-second execution time limit</strong> and you will encounter a timeout error. Don&#8217;t panic. Go to your WP installation and check the earliest tweet that was successfully imported. Return to your RSS file, and remove all entries prior to that, which should shave a sizeable chunk of bytes off the original RSS file. Reimport the file.</li>
<li>Install Alex King&#8217;s <a title="Twitter Tools by Alex King" href="http://wordpress.org/extend/plugins/twitter-tools/">TwitterTools</a> WP plugin. The plugin has quite a lot of function, but I configured it such that it only imports my tweets and post them. The plugin can also create a tweet from your WP post, but enabling this feature might cause a non-ending loop (although it is claimed that the plugin is designed to avoid such fireball of death, you should be smart enough to avoid it).</li>
<li>Get a theme. Doug has an excellent one, <a title="Theme files for my WP tweet archive" href="http://stopdesign.com/archive/2010/04/30/tweet-archive-theme-files.html">go get it</a>. Alternatively, you can modify any WP themes you want. The theme I am using for my tweet archive is a modification of <a title="Sandbox" href="http://www.plaintxt.org/themes/sandbox/">Sandbox</a>, modeled after Doug&#8217;s theme as well.</li>
<li>Regex. If you&#8217;re quick, you&#8217;ll notice that all imported tweets lack outbound links for @replies and #hashtags. I wrote a short php function to do this. Insert the following lines into your theme&#8217;s <code>functions.php</code> file:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Makes URLs, @usernames and #hastags in tweets clickable</span>
<span style="color: #000000; font-weight: bold;">function</span> tweet_replies_url_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Prevent premature texturizing</span>
	remove_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wptexturize'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Replaces username with clickable link</span>
	<span style="color: #000088;">$pattern_username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/\@(\w+)/'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$replace_username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'@&lt;a href=&quot;http://twitter.com/'</span><span style="color: #339933;">.</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;\1&lt;/a&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern_username</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace_username</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Replaces hashtag with clickable link</span>
	<span style="color: #000088;">$pattern_hashtag</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/\#([a-z][A-Z])(\w+)/'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$replace_hashtag</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#&lt;a title=&quot;Search Twitter for \2&quot; href=&quot;http://search.twitter.com/search?q=\2&quot;&gt;\2&lt;/a&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern_hashtag</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace_hashtag</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/* Uses internal WP command make_clickable to replace URLs with clickable link */</span>
	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> make_clickable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wptexturize'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'tweet_replies_url_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ol>
<p>For more information, you <a title="A browsable, searchable archive of tweets" href="http://stopdesign.com/archive/2010/03/02/browsable-searchable-archive-of-tweets.html">can read it up here</a>. Doug has done a great writeup on establishing your own Tweet Archive.</p>
<h2>tdy.co (<a title="tdy.co - A personal URL shortener" href="http://tdy.co/">link</a>)</h2>
<div id="attachment_10477" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/tdyco01.png" rel="lightbox[10470]"><img class="size-medium wp-image-10477" title="tdy.co - A personal URL shortener" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/tdyco01-600x266.png" alt="tdy.co - A personal URL shortener" width="600" height="266" /></a><p class="wp-caption-text">tdy.co - A personal URL shortener</p></div>
<p>When the .co domain was opened to the general public on the 21st of July, I wasn&#8217;t very sure what domain name do I want. The first thing that actually went through my mind was to purchase tmun.co because tmun.com was already parked (and I have no idea why). When searching for available domain names on GoDaddy I decided to try my luck and started jamming the searchform with 3 letter acronyms of my site, my nickname or my other pseudonyms.</p>
<p>Try.co, taken. Tsd.co, taken. Ted.co, taken. Tdy.co, still available. What?!</p>
<p>I jumped. Immediately I billed $26 to my credit card and snagged the domain name before anyone else does. I had no idea what I wanted to do with it until I saw Dean&#8217;s tweet about converting his new domain, djr.co, into a personal URL shortener and I thought, hell, why not?</p>
<p>I downloaded a fork of Shaun Inman&#8217;s <a title="Lessn" href="http://www.shauninman.com/archive/2009/08/17/less_n">Lessn</a>, developed by Alan Hoogan, called <a title="Lessnmore" href="http://lessnmore.net/">Lessnmore</a>. Lessn is a great simple tool and is a lot lighter than <a title="Yourls" href="http://yourls.org/">Yourls</a>, but it doesn&#8217;t support custom slugs unless I modify the database entry. I dug around and arrived at Lessnmore. It&#8217;s an extension of Lessn, and has a little more functionality with the same API hooks as Lessn.</p>
<p><a title="teddy-risation" href="http://tdy.co/1">tdy.co/1</a> points to this site :)</p>
<p>The tdy.co main page is a little plain. However, it is a significant example because it is my first HTML5 page. I&#8217;ve never really got into using HTML5 in my current projects because of my unfamiliarity with it, so I&#8217;m more than elated that it worked out just fine on tdy.co.</p>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2009/05/29/displaying-your-latest-tweet-wp-sans-plugins/" title="Displaying your latest tweet on WP, sans plugins">Displaying your latest tweet on WP, sans plugins</a></li><li><a href="http://teddy-o-ted.com/blog/2009/01/25/a-preview-of-html-5/" title="A Preview of HTML 5">A Preview of HTML 5</a></li><li><a href="http://teddy-o-ted.com/blog/2008/07/07/ie6-so-this-is-goodbye/" title="IE6, so this is goodbye!">IE6, so this is goodbye!</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/07/24/launching-two-new-sites/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Hello, World!</title>
		<link>http://teddy-o-ted.com/blog/2010/07/09/hello-world/</link>
		<comments>http://teddy-o-ted.com/blog/2010/07/09/hello-world/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 05:20:48 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://teddy-o-ted.com/?p=9984</guid>
		<description><![CDATA[I&#8217;m back after an absurdly long hiatus. Tumblr has got my attention most of the day because of a seemingly infinite amount of posts appear on my dashboard whenever I relief my bladder, get a drink, talk to my brother or catch my 40 winks. In comparison my blog is rather static since the past [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m back after an absurdly long hiatus. Tumblr has got my attention most of the day because of a seemingly infinite amount of posts appear on my dashboard whenever I relief my bladder, get a drink, talk to my brother or catch my 40 winks. In comparison my blog is rather static since the past few weeks and most of the traffic are actually coming from search engines, resulting in a very high bounce rate of around 80%. Pretty crazy!</p>
<p>Here&#8217;s a rough update of what happened in the past month:</p>
<h2>This layout &#8211; <em>teddy-risation Theta</em></h2>
<div id="attachment_10295" class="wp-caption aligncenter" style="width: 610px"><a href="http://teddy-o-ted.com/wp-content/uploads/2010/07/themehybridshowcase01.jpg" rel="lightbox[9984]"><img class="size-medium wp-image-10295" title="teddy-risation Theta" src="http://teddy-o-ted.com/wp-content/uploads/2010/07/themehybridshowcase01-600x375.jpg" alt="teddy-risation Theta" width="600" height="375" /></a><p class="wp-caption-text">teddy-risation Theta</p></div>
<p>I have less to love about the current layout, finally. I&#8217;m actually very excited because this WP theme has been up for the longest period of time &#8211; compared to the short-lived teddy-risation Epsilon who managed to provoke my ultimate wraith in less than three days online &#8211; but then it is getting very clumsy, heavy, bloated and complicated. This theme was developed before the days I knew more about hacking <code>functions.php</code> and I actually loaded multiple Javascript libraries (jQuery, Prototype and Scriptaculous) on the same page. Bad. Very bad.</p>
<p>Regardless of how flawed the current theme is, it actually found its way into<a title="Theme Hybrid's showcase" href="http://themehybrid.com/showcase/teddy-risation"> Theme Hybrid&#8217;s showcase</a> :D rate my theme if you feel like it, thanks!</p>
<h2>teddy-risation turned six!</h2>
<p>A week ago this site has finally turned six :) It&#8217;s another big milestone &#8211; since it&#8217;s fifth birthday, this site has turned into more like a place where I dump my design inspirations, coding tutorials and some photography works. There is less and less writing about my life, and I&#8217;m very much aware of it. Most of the personal stuff has been migrated to Tumblr.</p>
<p>Speaking of which, I have recently migrated my Tumblelog, too. It was a silly mistake that I made, to make my Tumblr as connected to my other online identities as this site was. It was a foolish decision, because I ended up having too many prying eyes and nosey folks stalking my Tumblr entries. A week ago I made the decision to replace my original Tumblr site with a dummy page, while its actual contents were clandestinely moved to a new location &#8211; and you&#8217;ll have to <a href="http://teddy-o-ted.com/contact/">ask me</a> if you have not been given access to the new Tumblr.</p>
<h2>Upgraded to WP3.0 Multisite</h2>
<p>Over the week I have also upgraded this WP installation to the latest version, which has integrated WPMU in it, too. After some tinkering with wp-config.php and the .htaccess files, I have managed to activate the multisite feature and now I&#8217;m actually running an additional WP site on the server.</p>
<p>I&#8217;ll keep you guys posted about what the new site is about. But basically it&#8217;s a WP blog that serves the sole purpose of backing up all my tweets ;)</p>
<p>If you need any help with implementing WP3.0&#8242;s multisite feature, feel free to <a title="Contact Me" href="http://teddy-o-ted.com/contact/">contact me</a>. I&#8217;ll help you as much as I could.</p>
<h2>Personal</h2>
<p>If you read my Tumblr you&#8217;ll probably knew what happened, but to others I could only say that something major happened around me life lately &#8211; I wouldn&#8217;t say that its unpleasant or something worth to be celebrated of. It&#8217;s neither of both. It is more like a process of discovery, learning, embracing and accepting.</p>
<p>My life was, for a moment, up in smokes for a few days a week ago, which explains pretty much what happened &#8211; not only I was not in the mood to celebrate this site&#8217;s 6th birthday, I also had to migrate my Tumblr because of me writing some really private stuff in there. Since then, things have pretty much stabilized and my life has returned to normal (hopefully so).</p>
<p>And to all those who sent my emails and left comments on my Tumblr, lending me support and dishing out really helpful advice, thank you. You know who you are ;)</p>
<p>I guess that&#8217;s all for this update! I&#8217;ll keep you guys posted, watch out this space.</p>
<h3  class="related_post_title">Random</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2009/06/01/happy-birthday-patrick/" title="Happy Birthday, Patrick!">Happy Birthday, Patrick!</a></li><li><a href="http://teddy-o-ted.com/blog/2004/10/27/its-ortus-carnival/" title="It&#8217;s Ortus Carnival!">It&#8217;s Ortus Carnival!</a></li><li><a href="http://teddy-o-ted.com/blog/2010/02/08/dining-at-ikea/" title="Dining at IKEA">Dining at IKEA</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/07/09/hello-world/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Broga Hill Experience</title>
		<link>http://teddy-o-ted.com/blog/2010/06/17/the-broga-hill-experience/</link>
		<comments>http://teddy-o-ted.com/blog/2010/06/17/the-broga-hill-experience/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 17:22:04 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Reaching Out]]></category>

		<guid isPermaLink="false">http://www.teddy-o-ted.com/?p=4711</guid>
		<description><![CDATA[I can&#8217;t believe how long have I not been updating this blog. I&#8217;d partly blame Tumblr (yea, I blog more often over there now) and partly because I&#8217;m currently interning with a local design firm. Plus, I&#8217;m juggling a design gig with Claudia, and then I have to fulfill my responsibilities as the publication officer [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t believe how long have I not been updating this blog. I&#8217;d partly blame Tumblr (yea, I blog more often over there now) and partly because I&#8217;m currently interning with a local design firm. Plus, I&#8217;m juggling a design gig with Claudia, and then I have to fulfill my responsibilities as the publication officer of my university&#8217;s photography club. Basically, it&#8217;s too many things and too little time.</p>
<p class="note">Most of the photos taken during this trip are done in the RAW format, and therefore most of them have been converted to pseudo-HDRs. There are only a handful of shots that remained unconverted. Sorry, once I have Photomatix I couldn&#8217;t stop myself!</p>
<p>My aunt, her boyfriend Josh, and I hiked Broga Hill in the early Friday morning a few weeks back. It was Vesak Day, a public holiday in Malaysia and we rose at 4.30 in the morning so that we could catch the sunrise shortly after we reach the peaks. I wouldn&#8217;t say that I&#8217;m an avid hiker, but I do love scaling hills a lot. Whenever I return to Malaysia, my aunt would bring me along to hike Gasing Hill, a popular hill among the suburban residents in my area. But then when her boyfriend came along she rarely asked me out already *laughs* I guess she has finally found someone to go with her.</p>
<p>We were taken aback by the sheer size of the crowd. Imagine hundreds of cars and people swarming around the oil palm plantation located at the foot of the hill at 5.30am in a remote town located far away from the city center. The sky was still dark and our surroundings were still pitch black. However, the chatters of the people and the beams of light from their torches slices through the darkness and silence of the morning.</p>
<p><em>This is so crazy,</em> I said to myself. I looked at my aunt and Josh. Both of them were silent, mouth agape. I&#8217;m not too sure if they were amused, amazed or astonished by the amount of people.</p>
<p>Along the way up the hill, people constantly flowed around us. There were families who rested along the way to let their young and old to catch a breather; there were teenage couples who couldn&#8217;t stop hugging while making their way up; and then there were groups of noisy, rambunctious adolescents who just couldn&#8217;t stop talking all the way up, at the top of their voice.</p>
<p>Suddenly, the entire hiking trip felt like a massive early morning pilgrimage.</p>
<p>There were many samaritans along the way up. There were several sharp turns and steep inclines that were hard to navigate in the dark, even when we were armed with LED torchlights. These people stood close to these danger areas and shone their torches at us and at the walkway, guiding us through. Midway up the hill, a landslide greeted us. It ran parallel to the track but there were many instances when the cliff came too close to our footpath for comfort. Nylon strings were tied between trees for us to hold on to our dear lives.</p>
<p>The hike gave me hope. You could see people pulling each other up steep slopes. Mommies were spotted pushing their little sons and daughters up. The elderlies were offered walking sticks spontaneously fashion out of fallen branches. People offering words of encouragement to each other as they laboriously navigated through crazy turns.</p>
<p>After around an hour&#8217;s worth of hiking, we emerged through the secondary tropical forest and onto landing full of weeds. Further ahead you could see yet another steep climb up a hill. The interesting thing is that the hill is no longer covered by trees or any tall foliage. It&#8217;s covered with weed. A windy and steep path led hikers to the first peak of Broga Hill, and we could see torchlights flashing. I thought they were fireflies.</p>
<p>The climb from the clearing up to the first peak was the craziest ever. I reckon the inclination to be around 45 degrees, and at some points they could be as steep as 50. However, human traffic has carved steps out of the footpath, making hiking a lot easier than the way less traveled.</p>
<p>Finally, we reached the first peak at 6.30am.  Although dawn is yet to break, I could see campers and a whole lot of people through the darkness. There was almost no standing space. My aunt, Josh and I found a secluded spot and decided not to move on to the other peaks because there were simply too many people. Like a swarm of angered bees, they went ferociously for the remaining peaks.</p>
<div id="attachment_4714" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_01.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_01-600x400.jpg" alt="Light trails on Broga Hill" title="Light trails on Broga Hill" width="600" height="400" class="size-medium wp-image-4714" /></a><p class="wp-caption-text">Light trails on Broga Hill</p></div>
<div id="attachment_4715" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_02.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_02-600x400.jpg" alt="Enjoying the view" title="Enjoying the view" width="600" height="400" class="size-medium wp-image-4715" /></a><p class="wp-caption-text">Enjoying the view</p></div>
<p>It took us awhile to find a less crowded spot on the barren peak. A few huge boulders were scattered around so we picked one that pricked our butts the least :) From left: my aunt and Josh. And then we started snapping away! </p>
<div id="attachment_4716" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_03.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_03-600x400.jpg" alt="People. And more People" title="People. And more People" width="600" height="400" class="size-medium wp-image-4716" /></a><p class="wp-caption-text">People. And more People</p></div>
<p>From the photo above you could see how crazeh the size of the crowd is. There was almost no standing space left, and if I was any shorter I would have drowned in a sea of sweaty backs and armpits. Everybody waited patiently for the sun to rise above the hills ahead, while new hikers kept walking past us to the remaining peaks.</p>
<div id="attachment_4717" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_04.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_04.jpg" alt="Windy Path Ahead" title="Windy Path Ahead" width="500" height="750" class="size-full wp-image-4717" /></a><p class="wp-caption-text">Windy Path Ahead</p></div>
<p>A snaking path brings hikers to the next 3 peaks. The boulder we sat on offered a panoramic view of the path leading to the remaining peaks, and I just snapped away, in awe of the sheer size of the crowd. </p>
<div id="attachment_4718" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_05.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_05.jpg" alt="Broga Hill, in infrared" title="Broga Hill, in infrared" width="500" height="750" class="size-full wp-image-4718" /></a><p class="wp-caption-text">Broga Hill, in infrared</p></div>
<p>The one and only infrared photo of the trip. I took a handful of infrared photos but I suspect it&#8217;s because of the low light conditions that made most of the photos unusable. This is the &#8220;<em>Goldilocks photo</em>&#8221; &#8211; it was not too dark, and yet the sun was yet to be seen (so there was barely any lens flare in the photo, which infrared photos are notoriously known to have). </p>
<div id="attachment_4719" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_06.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_06.jpg" alt="Through the Grasses" title="Through the Grasses" width="500" height="750" class="size-full wp-image-4719" /></a><p class="wp-caption-text">Through the Grasses</p></div>
<p>As the sky continued to brighten, the crowd gets stronger by the minute. More and more people starting surging from the jungle and oil palm plantation below and heading straight at us. All we could do is to hold our fort and hopefully there won&#8217;t be any rude intrusion onto our little boulder. </p>
<div id="attachment_4720" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_07.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_07.jpg" alt="Glowing" title="Glowing" width="500" height="750" class="size-full wp-image-4720" /></a><p class="wp-caption-text">Glowing</p></div>
<p>The weeds lay under the weak morning sky glow. The glow from the sky above seemed to bounce right off them :) pretty lovely. Taken with the trusty old KM f/1.7 lens. </p>
<div id="attachment_4721" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_08.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_08.jpg" alt="Awww! I smell romance in the air." title="Awww! I smell romance in the air." width="500" height="750" class="size-full wp-image-4721" /></a><p class="wp-caption-text">Awww! I smell romance in the air.</p></div>
<p>My aunt and her boyfriend Josh. Love is in the air. And I adore his tattoos, although I&#8217;m yet to ask him what they meant to him.</p>
<div id="attachment_4722" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_09.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_09-600x400.jpg" alt="Girl and Polaroid Camera" title="Girl and Polaroid Camera" width="600" height="400" class="size-medium wp-image-4722" /></a><p class="wp-caption-text">Girl and Polaroid Camera</p></div>
<p>Shortly after I took this photo, the girl called me over and asked for me help to take a group photo with her friends using that very camera. Pretty cool! An alternative crop of this photo is available <a title="Girl and Polaroid Camera, alternative crop" href="http://www.flickr.com/photos/teddy-rised/4666511242/in/set-72157624196132996/">here</a> ;) </p>
<div id="attachment_4723" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_10.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_10-600x400.jpg" alt="In her own little world" title="In her own little world" width="600" height="400" class="size-medium wp-image-4723" /></a><p class="wp-caption-text">In her own little world</p></div>
<p>A girl reads her book as her father (left) snaps away. I&#8217;m surprised how she managed to remain attentive throughout my entire stay on the peak because the crowd is extremely noisy &#8211; well, I couldn&#8217;t blame them for being disruptive because of the excitation from conquering Broga Hill and the prospect of seeing the sun rising before their eyes. An alternative crop of this photo is available <a href="http://www.flickr.com/photos/teddy-rised/4666524304/in/set-72157624196132996/" title="In her own little word, alternative crop">here</a>.</p>
<div id="attachment_4724" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_11.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_11-600x400.jpg" alt="The Crowded First Peak" title="The Crowded First Peak" width="600" height="400" class="size-medium wp-image-4724" /></a><p class="wp-caption-text">The Crowded First Peak</p></div>
<p>The first peak remained crowded throughout our stay. Everyone is looking at the direction where the sun is rising. </p>
<div id="attachment_4725" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_12.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_12-600x400.jpg" alt="The Sun is Out! #1" title="The Sun is Out! #1" width="600" height="400" class="size-medium wp-image-4725" /></a><p class="wp-caption-text">The Sun is Out! #1</p></div>
<div id="attachment_4726" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_13.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_13.jpg" alt="The Sun is Out! #2" title="The Sun is Out! #2" width="500" height="750" class="size-full wp-image-4726" /></a><p class="wp-caption-text">The Sun is Out! #2</p></div>
<p>The sun is finally out, and everybody snapped away furiously. My aunt was shown in various awkward poses because her boyfriend was playing the role of the artistic director in his photos, heh.</p>
<div id="attachment_4727" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_14.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_14.jpg" alt="Looking Over" title="Looking Over" width="500" height="750" class="size-full wp-image-4727" /></a><p class="wp-caption-text">Looking Over</p></div>
<p>I was looking over my aunt and her boyfriend, as I struggle to maintain my balance on yet another boulder. When this photo was taken I wished I had a fisheye lens with me because the horizon will definitely look damn good with it :)<br />
<div id="attachment_4728" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_15.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_15.jpg" alt="Heaven &amp; Earth" title="Heaven &amp; Earth" width="500" height="750" class="size-full wp-image-4728" /></a><p class="wp-caption-text">Heaven &#038; Earth</p></div></p>
<p>Another shot of the windy path leading to the other peaks. The wispy cloud caught my attention. My aunt joked that most of my photos will turn out to be photos filled with human heads. Well, she was definitely half right about that!</p>
<div id="attachment_4729" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_16.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_16-600x400.jpg" alt="On our way down #1" title="On our way down #1" width="600" height="400" class="size-medium wp-image-4729" /></a><p class="wp-caption-text">On our way down #1</p></div>
<div id="attachment_4730" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_17.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_17.jpg" alt="On our way down #2" title="On our way down #2" width="500" height="750" class="size-full wp-image-4730" /></a><p class="wp-caption-text">On our way down #2</p></div>
<p>We savoured enough of the magnificent views and decided that we should make our way back to the foot of the hill before the crowd makes it impossible to pass. Afterall, it&#8217;s a narrow path that bridges the peaks and the street below &#8211; and what really separates us between the peak, the queue, and our car parked way below is a good tumble down the hills :P People were already queueing up to get down. Can you imagine the number of people up there? </p>
<div id="attachment_4731" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_18.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_18.jpg" alt="Family of Four" title="Family of Four" width="500" height="750" class="size-full wp-image-4731" /></a><p class="wp-caption-text">Family of Four</p></div>
<p>A family of four admires the great view, oblivious to the crowd around them.<br />
<div id="attachment_4732" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_19.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_19.jpg" alt="Wispy Clouds" title="Wispy Clouds" width="500" height="750" class="size-full wp-image-4732" /></a><p class="wp-caption-text">Wispy Clouds</p></div></p>
<p>Definitely one of my favourite photos in this pack. It looks like the man&#8217;s head is steaming :P Oh and it&#8217;s the same people as the previous photo. Just that I photographed them from a lower angle.</p>
<div id="attachment_4733" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_20.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_20.jpg" alt="On our way down #3" title="On our way down #3" width="500" height="750" class="size-full wp-image-4733" /></a><p class="wp-caption-text">On our way down #3</p></div>
<p>We stopped at the steps along the path, carved out by human traffic, as we waited patiently for our turn to descend. Impatient queue-cutters were taking the easy but dangerous way down, which includes sliding down with their asses on a slippery, muddy slope.</p>
<div id="attachment_4734" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_21.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_21.jpg" alt="Common sense, or the lack thereof?" title="Common sense, or the lack thereof?" width="500" height="750" class="size-full wp-image-4734" /></a><p class="wp-caption-text">Common sense, or the lack thereof?</p></div>
<p>People please, stop wearing slippers to climb a hill. That&#8217;s not good, and you&#8217;re placing everyone in front of you in danger. Dumbasses that are the shining example of the imbecility.<br />
<div id="attachment_4735" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_22.jpg" rel="lightbox[4711]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/06/brogahill10_22.jpg" alt="On our way down #4" title="On our way down #4" width="500" height="750" class="size-full wp-image-4735" /></a><p class="wp-caption-text">On our way down #4</p></div></p>
<p>Finally, the queue is moving. Goodbye, Broga Hill!</p>
<h3  class="related_post_title">Random</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2010/05/13/randomizing-images-on-glider/" title="Randomizing Images on Glider">Randomizing Images on Glider</a></li><li><a href="http://teddy-o-ted.com/blog/2004/11/14/crab-eating/" title="Crab Eating">Crab Eating</a></li><li><a href="http://teddy-o-ted.com/blog/2005/03/11/sabbaticals-5-faint-fainting-fainted/" title="Sabbaticals #5 &#8211; Faint, Fainting, Fainted">Sabbaticals #5 &#8211; Faint, Fainting, Fainted</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/06/17/the-broga-hill-experience/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>WP Widget: Load posts in a category</title>
		<link>http://teddy-o-ted.com/blog/2010/05/22/wp-widget-load-posts-in-a-category/</link>
		<comments>http://teddy-o-ted.com/blog/2010/05/22/wp-widget-load-posts-in-a-category/#comments</comments>
		<pubDate>Fri, 21 May 2010 17:15:41 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.teddy-o-ted.com/?p=4702</guid>
		<description><![CDATA[As I was tinkering with Theme Hybrid lately to prepare myself for major design jobs up ahead, I felt that I should no longer try to hardcode anything into the hybrid sidebar. I have to admit that it is indeed lucrative to simply put a copy of sidebar-primary.php in the child theme folder &#8211; identifical [...]]]></description>
			<content:encoded><![CDATA[<p>As I was tinkering with <a href="http://themehybrid.com/" title="Theme Hybrid">Theme Hybrid</a> lately to prepare myself for major design jobs up ahead, I felt that I should no longer try to hardcode anything into the hybrid sidebar. I have to admit that it is indeed  lucrative to simply put a copy of <code>sidebar-primary.php</code> in the child theme folder &#8211; identifical files will force Hybrid to load the file from child theme folder instead. Afterall, one will simply have to copy the file, remove the dynamic sidebar codes and replace with your own hardcoded sidebar elements.</p>
<p>Justin Tadlock, the creator and developer behind the Hybrid framework (of which the current WP theme is built on), has written a meticulous and beautiful tutorial on <a href="http://justintadlock.com/archives/2009/05/26/the-complete-guide-to-creating-widgets-in-wordpress-28" title="The complete guide to creating widgets in WordPress 2.8">how to create a widget from scratch for WP2.8</a> and above. His tutorial is straight-forward and simple &#8211; more importantly, he provided a sample widget code that you can download at the end of the day and tinker with it on your own site.</p>
<p>There are two ways to introduce widgets into your WordPress installation:</p>
<ol>
<li>Through a plugin file, which you place in your <code>/[blog-root]/wp-content/plugins/</code> folder, or</li>
<li>Through your theme&#8217;s own <code>functions.php</code> file located in <code>/[blog-root]/wp-content/themes/[theme-folder]/</code>. If the file is not present, you can create it yourself but most probably the theme does not support widget and further tweaking of <code>sidebar.php</code> is needed (Jeff Starr explains it all in <a href="http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/" title="How to Widgetize Your WordPress Theme in 2 Steps">his tutorial</a>).</li>
</ol>
<p>I will not be covering how to write a widget in this article &#8211; I recommend you to read <a href="http://justintadlock.com/archives/2009/05/26/the-complete-guide-to-creating-widgets-in-wordpress-28" title="The complete guide to creating widgets in WordPress 2.8">Justin&#8217;s tutorial</a> if you need to understand any part of the code I&#8217;m posting below. Since I&#8217;m working on Theme Hybrid, which has a handful of widget-ready areas, I will no longer have to go through the process of making my child theme widget friendly.</p>
<h2>The Widget &#8211; Loading Posts in a Category</h2>
<p>I don&#8217;t have an official name for the widget &#8211; and I don&#8217;t have any intention to. There are too many plugins out there who offer a similar, or perhaps <em>improved</em>, functionality. What I&#8217;m presenting is a piece of code that you can simply put in your theme&#8217;s <code>functions.php</code> file without even needing to install a plugin or whatsoever.</p>
<p>Of course, if you want to hardcode it, it&#8217;s rather simple:</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;">$recent</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;cat=[category_ID]&amp;showposts=[integer]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$recent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><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>
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<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>&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<p><em>Why do it the hard way?</em>, you may ask. It&#8217;s simple &#8211; you don&#8217;t have to modify anything in your theme file in the future. Action and filter hooks have a special place in WordPress, which allows us to construct child themes from frameworks without needing to touch any of the core files at all &#8211; except for a single <code>functions.php</code> file in your child theme&#8217;s folder. When the framework is upgraded to a new version, one no longer needs to worry about porting the changes over to the new version, or go through the same mind-wrecking cycle of comparing new and old codes.</p>
<p>What the widget does is actually simple &#8211; to load posts from a specific category. You will enter the category ID and let the plugin do the crunching. Of course, more customization options are offered too. Just in case you&#8217;re curious, this is how the widget looks like in WP2.9:</p>
<div id="attachment_4706" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/wpwidget_postsincategory01.png" rel="lightbox[4702]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/wpwidget_postsincategory01.png" alt="WP Widget: Load posts in a category" title="WP Widget: Load posts in a category" width="600" height="580" class="size-full wp-image-4706" /></a><p class="wp-caption-text">WP Widget: Load posts in a category</p></div>
<h2>The Code</h2>
<p>Simply place the codes below sequentially into your theme&#8217;s <code>functions.php</code> file. After that, navigate to the widget page from your WP dashboard and you should see a new widget named &#8220;List Post in a Specific Category&#8221;. I think I heard a silent scream over the naming of the widget, but that&#8217;s the best the inner linguist in me can go. Go ahead and give it a new name if you feel like it.</p>
<p>Most of the code is modeled after Justin&#8217;s very helpful, heavily annotated example widget code. I have removed some of the comments (that&#8217;s why it&#8217;s better that you read his tutorial beforehand) for simplicity&#8217;s sake. The overall structure remains the same, except for the core functionality of the widget itself.</p>
<h3>Add action hook</h3>
<p>The first thing we need to do is to register the widget to a function, and then hook the function up with <code>widgets_init</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Load Custom Theme Widgets</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_in_category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_widgets'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Declaring a new widget</h3>
<p>After adding the action hook, we will need to declare the new widget. We go through a few mandatory lines that describes the widget and assigns it a unique identifier. If you are intending to replace any of the variables, make sure to replicate the changes downstream as well &#8211; simply use the &#8220;Search and replace all&#8221; tool (or any equivalent) that will help you make global changes to the identifiers.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> posts_in_category <span style="color: #000000; font-weight: bold;">extends</span> WP_Widget <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Custom Theme Widget: Display posts from a specific category</span>
	<span style="color: #000000; font-weight: bold;">function</span> posts_in_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$widget_ops</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'classname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A widget that displays posts from a specific category'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$control_ops</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'width'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">350</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'id_base'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'posts-in-category-widget'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WP_Widget</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'posts-in-category-widget'</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'List Posts in a Specific Category'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_ops</span><span style="color: #339933;">,</span> <span style="color: #000088;">$control_ops</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Determine what will the widget display on screen</h3>
<p>Of course, when your widget is activated, you would want to present saved data (if input from the user is allowed) in the widgetized area. We will declare 5 different variables, namely:</p>
<ol>
<li><code>$title</code> &#8211; The title of the widget that will appear in the widgetized area, usually wrapped between header tags.</li>
<li><code>$category_id</code> &#8211; The ID of the category where posts will be fetched from.</li>
<li><code>$post_count_limit</code> &#8211; The maximum number of posts to be queried from the database and be displayed.</li>
<li><code>$post_orderby</code> &#8211; How do you want to arrange the posts in the list? By author, title, date, modified and etc. You will be given the option to choose.</li>
<li><code>$post_offset</code> &#8211; How many posts to skip/pass before displaying the first post.</li>
</ol>
<p>For more information about the query_posts() function, you can <a href="http://codex.wordpress.org/Function_Reference/query_posts" title="Function Reference/query posts">refer to the WordPress codex</a>.</p>
<p>To fetch the code, we will use the template tag <code>get_posts()</code> (<a href="http://codex.wordpress.org/Template_Tags/get_posts" title="Template Tags/get posts">how to use it?</a>) to help to fetch posts from a specific category.</p>
<p>Don&#8217;t forget to wrap the displayed content between <code>echo $before_widget;</code> and <code>echo $after_widget;</code> &#8211; we do not define what wraps around the widget, because that is usually pre-determined by the theme in use already.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #666666; font-style: italic;">// Displaying widget on screen</span>
	<span style="color: #000000; font-weight: bold;">function</span> widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$category_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$post_count_limit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$post_orderby</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$post_offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after_title</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$category_posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$category_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;numberposts='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_count_limit</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;orderby='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_orderby</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;offset= '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post_offset</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$category_posts_result</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$category_posts_result</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</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> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$category_posts_result</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$category_posts_result</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;No posts found in this category&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$category_posts_result</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Updating widget settings</h3>
<p>We cannot forget that we&#8217;re allowing users to input the category IDs and other parameters in the widget from the dashboard. However, in order to allow changes to be made to the variables, we will have to allow them to update the widget parameters.</p>
<p>The <code>strip_tags()</code> function is used to remove any tags &#8211; we only want texts to be entered, not tags. The reason why <code>post_orderby</code> doesn&#8217;t need to be passed through the <code>strip_tags()</code> function is simply because it obtains its values from a dropdown list, which does not contain any tags at the first place.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #666666; font-style: italic;">// Update widget settings</span>
	<span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_instance</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>User input interface</h3>
<p>In order for a user to enter specific parameters, we have to set up a user interface. The following piece of code simply sets up the input fields for the user &#8211; a few text inputs and a dropdown list.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	// Widget setting controls
	function form($instance) {
		$defaults = array('title' =&gt; __('Category Name', 'posts-in-category'), 'category_id' =&gt; __('1', 'posts-in-category'), 'post_count_limit' =&gt; __('5', 'posts-in-category'), 'post_orderby' =&gt; 'date', 'post_offset' =&gt; __('0', 'posts-in-category'));
		$instance = wp_parse_args((array) $instance, $defaults); ?&gt;
		&lt;p&gt;
			&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;
			&lt;input id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; style=&quot;width:100%;&quot; /&gt;
		&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Category ID:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;
			&lt;input id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; style=&quot;width: 100%;&quot; /&gt;
		&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Post Count Limit:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;
			&lt;input id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_count_limit'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; style=&quot;width: 100%;&quot; /&gt;
		&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Offset:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;
			&lt;input id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_offset'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; style=&quot;width: 100%;&quot; /&gt;
		&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Order Posts By:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'posts-in-category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/label&gt;
			&lt;select id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_orderby'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;widefat&quot; style=&quot;width:100%;&quot;&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'author'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;author&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'date'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;date&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;title&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'modified'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;modified&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;parent&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;ID&lt;/option&gt;
				&lt;option <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'rand'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;rand&lt;/option&gt;
			&lt;/select&gt;
		&lt;/p&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>The final code</h3>
<p>I have also uploaded a copy of the entire piece of code. Simply download it, copy it in its entirety and paste in anywhere in your theme&#8217;s <code>function.php</code> file &#8211; okay, not really <em>anywhere</em>, but do stay within the <code>&lt;?php &gt;</code> tags that are found on the first and last line in the file.</p>
<p class="download download-txt" title="Download link for WP Widget - Posts in Category"><a href="http://teddy-o-ted.com/download/11" title="Download link for WP Widget - Posts in Category."><span class="download-title"><strong>Download</strong>: WP Widget - Posts in Category</span><span class="download-stats">Version 1.2 &#92; File size: 4.99 KB &#92; 116 downloads</span><span class="download-desc">A WordPress widget that allows you to load posts from a specific category with several other customizable parameters.</span></a></p>
<h2>Last</h2>
<p>If you have any problems regarding the widget, or any suggested improvements, feel free to reach me through the comments or the <a href="http://www.teddy-o-ted.com/contact/" title="Contact the author">contact page</a>. Thank you!</p>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2008/05/14/designing-is-fun-a-wordpress-poster/" title="Designing is Fun &#8211; a Wordpress Poster">Designing is Fun &#8211; a Wordpress Poster</a></li><li><a href="http://teddy-o-ted.com/blog/2009/05/29/displaying-your-latest-tweet-wp-sans-plugins/" title="Displaying your latest tweet on WP, sans plugins">Displaying your latest tweet on WP, sans plugins</a></li><li><a href="http://teddy-o-ted.com/blog/2009/05/24/wp-theme-teddy-risation-theta/" title="WP theme: teddy-risation Theta">WP theme: teddy-risation Theta</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/05/22/wp-widget-load-posts-in-a-category/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NTU HDR Photography</title>
		<link>http://teddy-o-ted.com/blog/2010/05/16/ntu-hdr-photography/</link>
		<comments>http://teddy-o-ted.com/blog/2010/05/16/ntu-hdr-photography/#comments</comments>
		<pubDate>Sun, 16 May 2010 10:26:02 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[HDR]]></category>
		<category><![CDATA[NTU]]></category>
		<category><![CDATA[Singapore]]></category>

		<guid isPermaLink="false">http://www.teddy-o-ted.com/?p=4692</guid>
		<description><![CDATA[My summer vacation has official started. All will end on the 30th of August, so I have around three and a half month&#8217;s time to do whatever I want. Of course, I will be picking up design jobs (and perhaps some writing as well, given that I write on a whim) along the way and [...]]]></description>
			<content:encoded><![CDATA[<p>My summer vacation has official started. All will end on the 30th of August, so I have around three and a half month&#8217;s time to do whatever I want. Of course, I will be picking up design jobs (and perhaps some writing as well, given that I write on a whim) along the way and see how it goes. After a few weeks of work I finally completed the <a href="http://jotter.teddy-o-ted.com/post/603088813/designing-a-new-site-for-my-club-i-hope-itll-be" title="Mockup for PVS website">first mockup</a> for my club&#8217;s new site design. The old website was in shambles and we needed a new face badly.</p>
<p>I&#8217;m barely into the second day at home and I&#8217;m missing Singapore a lot. I miss the freedom to leave my room anytime I want and roam the streets of Singapore, fearless. In Malaysia the situation is a little different, I will have to be more cautious when I&#8217;m out and will have to try avoid late night outs at all costs.</p>
<p>A few weeks back, I walked around my university in the evening. I was nearing the completion of my second academic year in my university and I simply could not believe that I&#8217;m already half way through now. Two more years down the road I will graduate, then toil and tumble in the real working world.</p>
<p>The HDR photos below are merged from photos of identical scenes taken at different exposure settings (with bracketed exposure option turned on). If you want to know how to create HDRs, <a href="http://www.teddy-o-ted.com/tutorials/hdr-merging-tweaking-tutorial/" title="HDR Merging &amp; Tweaking Tutorial">read this tutorial</a>.</p>
<div id="attachment_4695" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr03.jpg" rel="lightbox[4692]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr03-600x400.jpg" alt="School of Arts, Humanities and Social Sciences" title="School of Arts, Humanities and Social Sciences" width="600" height="400" class="size-medium wp-image-4695" /></a><p class="wp-caption-text">School of Arts, Humanities and Social Sciences</p></div>
<div id="attachment_4693" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr01.jpg" rel="lightbox[4692]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr01-600x400.jpg" alt="School of Arts, Humanities and Social Sciences - Love the cuboidal structures." title="School of Arts, Humanities and Social Sciences - Love the cuboidal structures." width="600" height="400" class="size-medium wp-image-4693" /></a><p class="wp-caption-text">School of Arts, Humanities and Social Sciences - Love the cuboidal structures.</p></div>
<p>The building that houses the school of humanities, arts and social sciences is the latest addition to the sprawling university campus. It has a minimalist touch to it, with a simple colour scheme of mainly black, white, grey and earthy tones. I haven&#8217;t got the chance to explore the building much, but when I visited my academic writing tutor in the building, the interiors were very simple too. Their carpet smells nice though.</p>
<div id="attachment_4694" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr02.jpg" rel="lightbox[4692]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr02-600x400.jpg" alt="The fountain plaza underneath the blue skies" title="The fountain plaza underneath the blue skies" width="600" height="400" class="size-medium wp-image-4694" /></a><p class="wp-caption-text">The fountain plaza underneath the blue skies</p></div>
<p>This is the fountain that connects the north academic complex and the students services center. The latter is tucked behind the trees in the background so you can&#8217;t see it quite clearly. On clear warm days you would see the birds drinking from the fountain. How adorable :) </p>
<div id="attachment_4696" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr04.jpg" rel="lightbox[4692]"><img src="http://www.teddy-o-ted.com/wp-content/uploads/2010/05/ntuhdr04-600x400.jpg" alt="Outside the administration office" title="Outside the administration office" width="600" height="400" class="size-medium wp-image-4696" /></a><p class="wp-caption-text">Outside the administration office</p></div>
<p>A wide avenue brings visitor to the academic complex and the Nanyang auditorium, as well as the carparks located in the north academic complex. When we have visitors from other institutions or nations visiting, their tour buses would line the avenue, adding more life and vibrancy to this quiet stretch of campus road. Except for main functions, this place is usually deserted of vehicular and human traffic.</p>
<p>If you&#8217;re interested to view more photos of NTU, you can browse the Photography category. I have also published <a href="http://www.teddy-o-ted.com/daily-life/end-of-a-dreadful-week/" title="End of a dreadful week">two</a> <a href="http://www.teddy-o-ted.com/daily-life/my-valentines-day/" title="My Valentineâ€™s Day">entires</a> containing infrared photos taken on the campus too.</p>
<p>Have a great week ahead, folks!</p>
<h3  class="related_post_title">Related</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2009/03/28/tgif-thank-god-its-friday/" title="TGIF: Thank God It&#8217;s Friday!">TGIF: Thank God It&#8217;s Friday!</a></li><li><a href="http://teddy-o-ted.com/blog/2009/08/06/bokeh-portraits/" title="Bokeh portraits">Bokeh portraits</a></li><li><a href="http://teddy-o-ted.com/blog/2009/03/06/the-sentosa-outing/" title="The Sentosa Outing">The Sentosa Outing</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/05/16/ntu-hdr-photography/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Randomizing Images on Glider</title>
		<link>http://teddy-o-ted.com/blog/2010/05/13/randomizing-images-on-glider/</link>
		<comments>http://teddy-o-ted.com/blog/2010/05/13/randomizing-images-on-glider/#comments</comments>
		<pubDate>Wed, 12 May 2010 20:37:21 +0000</pubDate>
		<dc:creator>Terry</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.teddy-o-ted.com/?p=4678</guid>
		<description><![CDATA[Recently, a friend and reader of mine, Trina, asked me on Facebook on how did I manage to get the images you see in the current design&#8217;s header to load randomly upon page load. The images in the header are loaded into a glider container, which I used Glider.js to allow for smooth transitioning among [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, a friend and reader of mine, <a href="http://www.blistersinmay.org/" title="Trina">Trina</a>, asked me on Facebook on how did I manage to get the images you see in the current design&#8217;s header to load randomly upon page load. The images in the header are loaded into a glider container, which I used <a href="http://www.teddy-o-ted.com/tutorials/compacting-contents-using-glider-script/" title= Compacting contents using Glider script"">Glider.js</a> to allow for smooth transitioning among the images.</p>
<p>In this tutorial, I will not be covering the details of constructing a glider groundup because that has been covered in a previous tutorial,  <a href=http://www.teddy-o-ted.com/tutorials/compacting-contents-using-glider-script/" title=" Compacting contents using Glider script">Compacting contents using Glider script</a>. I will be covering more on how we will be loading in images using php.</p>
<p>There are many other gallery/glider scripts that use different javascript libraries out there &#8211; Glider.js relies on scriptaculous and prototype, which I know have fallen out of favour as jQuery becomes more widely adopted. However, the basic construction remains the same and the steps below will still remain relevant to those using</p>
<h2>Setting up the Glider</h2>
<p>The basic construct of a typical glider will be as follow, according to the Glider tutorial:</p>
<ol class="code">
<li><code>&lt;div id="glider"&gt;</code></li>
<li class="indent1"><code>&lt;div class="scroller"&gt;</code></li>
<li class="indent2"><code>&lt;div class="content"&gt;</code></li>
<li class="indent3"><code>&lt;div id="section1" class="section"&gt;...&lt;/div&gt;</code></li>
<li class="indent3"><code>&lt;div id="section2" class="section"&gt;...&lt;/div&gt;</code></li>
<li class="indent3"><code>&lt;div id="section3" class="section"&gt;...&lt;/div&gt;</code></li>
<li class="indent2"><code>&lt;/div&gt;</code></li>
<li class="indent1"><code>&lt;/div&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
<li><code>&lt;script type="text/javascript" charset="utf-8"&gt;var my_glider = new Glider('glider', {duration:0.5});&lt;/script&gt;</code></li>
</ol>
<p>Instead of placing texts within each individual sections in the previous tutorial, we will be inserting images into the <code>&lt;div&gt;</code> elements instead:</p>
<ol class="code">
<li><code>&lt;div id="glider"&gt;</code></li>
<li class="indent1"><code>&lt;div class="scroller"&gt;</code></li>
<li class="indent2"><code>&lt;div class="content"&gt;</code></li>
<li class="indent3"><code>&lt;div id="section1" class="section"&gt;</code></li>
<li class="indent4"><code>&lt;img src=&quot;...&quot; alt=&quot;...&quot; title=&quot;...&quot; /&gt;</code></li>
<li class="indent3"><code>&lt;/div&gt;</code></li>
<li class="indent3"><code>&lt;div id="section2" class="section"&gt;</code></li>
<li class="indent4"><code>&lt;img src=&quot;...&quot; alt=&quot;...&quot; title=&quot;...&quot; /&gt;</code></li>
<li class="indent3"><code>&lt;/div&gt;</code></li>
<li class="indent3"><code>&lt;div id="section3" class="section"&gt;</code></li>
<li class="indent4"><code>&lt;img src=&quot;...&quot; alt=&quot;...&quot; title=&quot;...&quot; /&gt;</code></li>
<li class="indent3"><code>&lt;/div&gt;</code></li>
<li class="indent2"><code>&lt;/div&gt;</code></li>
<li class="indent1"><code>&lt;/div&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
<li><code>&lt;script type="text/javascript" charset="utf-8"&gt;var my_glider = new Glider('glider', {duration:0.5});&lt;/script&gt;</code></li>
</ol>
<p>But then of course, we will be inserted images dynamically into the glider, and not by copy and pasting every single line. We will be using the for loop for this &#8211; keep this in view, we&#8217;ll come back to the for loop later.</p>
<h2>Rotating the images</h2>
<p>My strategy was very rudimentary and perhaps imperfect, so if you have any improvements, feel free to voice up in the comments section below. The strategy is simple &#8211; to ensure a wide variety of images, I cluster my images into different folders based on the theme. Let&#8217;s say we want to rotate photos of different types &#8211; architecture, food, street and people. I would love to display a random image from each type. What I do is to place the images in different folders located in a main folder called <code>/gallery/</code> &#8211; let&#8217;s say 10 photos in a folder named <code>/ach/</code> (so it&#8217;s location will be <code>/gallery/ach/</code>), and so on and so forth for the remaining categories.</p>
<p>Now we will need to make a request to the server as the page loads &#8211; asking it to serve us a random image from each category. This is achieved by using the <a href="http://www.alistapart.com/articles/randomizer/" title="Random Image Rotation">lightweight 4kb image rotation script</a> (view <a href="http://www.alistapart.com/d/randomizer/rotate.txt" title="Random Image Rotation (Source)">PHP source</a>) written by Dan Benjamin for A List Apart. Place the file <code>rotate.php</code> into each folder, and when we load the PHP file as an image source, we will be served a random image by the php file, for example:</p>
<pre><code>&lt;img src=&quot;/ach/rotate.php&quot; alt=&quot;Photo - Architecture&quot; title=&quot;Photo - Architecture&quot; /&gt;</code></pre>
<p>However, we will also need to jumble up the sequence of which the category are loaded. Therefore, randomity of the images come in 2 forms &#8211; an image is randomly loaded from a category, and the order of the images are further randomized.</p>
<h2>Jumbling up the order of images</h2>
<p>What we need to do to jumble up the order of the image will be as follow:</p>
<ol>
<li>Create an array with a strings</li>
<li>Shuffle the array so that each string will be called in random order</li>
<li>Execute a for loop so that we run the loop as many times as the size of the array</li>
<li>In the for loop, load rotate.php from each category folder</li>
</ol>
<p>And the ideas above can be translated into php as seen below:</p>
<ol class="code">
<li><code>&lt;?php</code></li>
<li><code>$gliderdata = array(</code></li>
<li class="indent1"><code>'ach|Architecture',</code></li>
<li class="indent1"><code>'fod|Food',</code></li>
<li class="indent1"><code>'str|Street'</code></li>
<li class="indent1"><code>'ppl|People',</code></li>
<li><code>);</code></li>
<li><code>shuffle($gliderdata);</code></li>
<li><code>for ($i = 0; $i &lt; count($gliderdata); $i++)</code></li>
<li class="indent1"><code>{</code></li>
<li class="indent1"><code>$gliderimg = explode('|', $gliderdata[$i]);</code></li>
<li class="indent1"><code>echo '&lt;div class=&quot;section&quot; id=&quot;section'.($i+1).'&quot;&gt;&lt;img src=&quot;'.get_bloginfo(stylesheet_directory).'/gallery/'.$gliderimg[0].'/rotate.php&quot; alt=&quot;Photo - '.$gliderimg[1].'&quot; title=&quot;Photo - '.$gliderimg[1].'&quot; /&gt;&lt;/div&gt;';</code></li>
<li class="indent1"><code>}</code></li>
<li><code>?&gt;</code></li>
</ol>
<p>In the for loop, what I did was to explode the string in <code>$gliderdata</code> with &#8216;|&#8217; as the delimiter &#8211; for example, if we explode <code>ach|Architecture</code>, we will separate them into <code>ach</code> and <code>Architecture</code> &#8211; they will be referenced as <code>$gliderimg[0]</code> and <code>$gliderimg[1]</code> respectively.</p>
<p>After that, we will echo the individual sections of the glider which will house the image elements. The sections will be assigned a unique identifier, <code>section'.($i+1).'</code>, will mean that for each iteration of the for loop, the identifier will reflect the number of iterations. The reason why <code>$i+1</code> is used is because <code>$i</code> starts from zero but the section identifier has to start from &#8220;section1&#8243; and more.</p>
<p>I have placed the <code>/gallery/</code> folder into my WordPress theme folder, but of course you can use a static URL in its place. Instead of using <code>'.get_bloginfo(stylesheet_directory).'/gallery/'.$gliderimg[0].'/rotate.php</code>, we can use <code>http://yoursite.com/gallery'.$gliderimg[0].'/rotate.php</code>. Remember that <code>$gliderimg[0]</code> refers to the name of the folder while <code>$gliderimg[1]</code> refers to the description.</p>
<p>In short, the elements in the array should be formatted with this in mind: <code>'[foldername]|[description]',</code>. Whenever you add a new directory to the gallery folder, remember to add a new line to the array with the new subfolder name and a description if you feel like it. Each subfolder should contain photos and the <code>rotate.php</code> file.</p>
<h2>Final code</h2>
<p>We compile everything together into a decent glider with does not only jumble the sequence of images, but also loads a random image from a folder.</p>
<ol class="code">
<li><code>&lt;div id="glider"&gt;</code></li>
<li class="indent1"><code>&lt;div class="scroller"&gt;</code></li>
<li class="indent2"><code>&lt;?php</code></li>
<li class="indent2"><code>$gliderdata = array(</code></li>
<li class="indent3"><code>'ach|Architecture',</code></li>
<li class="indent3"><code>'fod|Food',</code></li>
<li class="indent3"><code>'str|Street'</code></li>
<li class="indent3"><code>'ppl|People',</code></li>
<li class="indent2"><code>);</code></li>
<li class="indent2"><code>shuffle($gliderdata);</code></li>
<li class="indent2"><code>for ($i = 0; $i &lt; count($gliderdata); $i++)</code></li>
<li class="indent3"><code>{</code></li>
<li class="indent3"><code>$gliderimg = explode('|', $gliderdata[$i]);</code></li>
<li class="indent3"><code>echo '&lt;div class=&quot;section&quot; id=&quot;section'.($i+1).'&quot;&gt;&lt;img src=&quot;'.get_bloginfo(stylesheet_directory).'/gallery/'.$gliderimg[0].'/rotate.php&quot; alt=&quot;Photo - '.$gliderimg[1].'&quot; title=&quot;Photo - '.$gliderimg[1].'&quot; width=&quot;270&quot; height=&quot;180&quot; /&gt;&lt;/div&gt;';</code></li>
<li class="indent3"><code>}</code></li>
<li class="indent2"><code>?&gt;</code></li>
<li class="indent1"><code>&lt;/div&gt;</code></li>
<li><code>&lt;/div&gt;</code></li>
<li><code>&lt;script type="text/javascript" charset="utf-8"&gt;var my_glider = new Glider('glider', {duration:0.5});&lt;/script&gt;</code></li>
</ol>
<p>If you have any questions, feel free to contact me, or ask in the comments section.</p>
<h3  class="related_post_title">Random</h3><p>Related posts that might interest you:</p><ul class="related_post"><li><a href="http://teddy-o-ted.com/blog/2004/07/02/ms-wuns-nightmare/" title="Ms Wun&#8217;s Nightmare">Ms Wun&#8217;s Nightmare</a></li><li><a href="http://teddy-o-ted.com/blog/2005/07/06/upgrading-wordpress-2/" title="Upgrading WordPress">Upgrading WordPress</a></li><li><a href="http://teddy-o-ted.com/blog/2004/12/19/me-suntec-city/" title="Me @ Suntec City">Me @ Suntec City</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teddy-o-ted.com/blog/2010/05/13/randomizing-images-on-glider/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.164 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-09-03 01:36:52 -->
