<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Anthology of Ideas &#187; Web Developing</title>
	<atom:link href="http://anthologyoi.com/archive/dev/feed" rel="self" type="application/rss+xml" />
	<link>http://anthologyoi.com</link>
	<description>Anthology of Ideas is an archive of thoughts and form.</description>
	<lastBuildDate>Sat, 03 Mar 2012 11:16:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Insert an image into a WordPress Post with a plugin.</title>
		<link>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html</link>
		<comments>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:15:42 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[wordress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/insert-an-image-into-a-wordpress-post-with-a-plugin.html</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>So in a project I&#8217;m working on I need to use a normal form to insert a post into the database. My client wanted the form to also add an image to the post. Furthermore, the image must be inserted using normal WordPress methods. The code below is the minimum required to insert an image into the database and attach it to a specific post.</p>
<p><pre class="brush: php">include_once(ABSPATH.&#039;/wp-admin/includes/media.php&#039;);
	include_once(ABSPATH.&#039;/wp-admin/includes/file.php&#039;);
	include_once(ABSPATH.&#039;/wp-admin/includes/image.php&#039;);
	
//	$id is the id of the post being inserted
//	$name is actually the name of the form input that uploaded the file so WP can access it using $_FILE[$name]
	media_handle_upload($name,$id);</pre></p>
<p>If you are inserting a new post, it makes sense to have the line <span class="inline-code">$id = wp_insert_post($post_data);</span> before this.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Short Ajax Script</title>
		<link>http://anthologyoi.com/dev/short-ajax-script.html</link>
		<comments>http://anthologyoi.com/dev/short-ajax-script.html#comments</comments>
		<pubDate>Tue, 13 May 2008 15:40:50 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/minimalist-ajax-script.html</guid>
		<description><![CDATA[I wanted to see how small you could make a fully functional AJAX script that worked cross-browser and degraded gracefully, so I went through an old custom AJAX script and made it as small as I possibly could. In the &#8230; <a href="http://anthologyoi.com/dev/short-ajax-script.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="flickrImage_4" class="wp-caption alignleft" style="width: 250px"><a href="http://www.flickr.com/photos/jaywood/" rel="nofollow"  target="_blank"><img src="http://farm7.static.flickr.com/6065/6126357875_ca3058c8fd_m.jpg" width="240" height="160" /></a><p class="wp-caption-text">AJAX - it</p></div>
<p>I wanted to see how small you could make a fully functional AJAX script that worked cross-browser and degraded gracefully, so I went through an old custom AJAX script and made it as small as I possibly could. In the resulting AJAX scripts, the post version is 410 characters and the GET version is only 359 characters long. The scripts are fully functional and accept the following parameters: URL, DATA (in string form), and ELEMENT (to update).</p>
<p>The scripts could be a little smaller, but it would really kill readability. </p>
<h3>&#8220;Get&#8221; AJAX Script</h3>
<p><pre class="brush: php">function a(l,d,u){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
r.open(&#039;GET&#039;, l+&#039;?&#039;+d, true);r.send(d);
}
}</pre></p>
<h3>&#8220;Post&#8221; AJAX Script</h3>
<p><pre class="brush: php">function b(l,d,u){
try{r = new XMLHttpRequest();} catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);} catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML=r.responseText;}}
r.open(&#039;POST&#039;, l, true);r.setRequestHeader(&#039;Content-type&#039;, &#039;application/x-www-form-urlencoded&#039;);r.send(d);
}
}</pre></p>
<h3>Combined AJAX Script</h3>
<p>This combined script also accepts a fourth parameter &#8216;p&#8217; that should evaluate true if the data is to be sent by post.</p>
<p><pre class="brush: php">function a(l,d,u,p){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
if(p){r.open(&#039;POST&#039;, l, true);r.setRequestHeader(&#039;Content-type&#039;, &#039;application/x-www-form-urlencoded&#039;);}else{r.open(&#039;GET&#039;, l+&#039;?&#039;+d, true);}
}
}</pre></p>
<p>Demo: (Sorry but you will have to go to the full page so the JavaScript is loaded.) <span id="more-220"></span><br />
<a href="?p=220" onclick="b('http://anthologyoi.com/index.php','p=220','hi'); return false;">Click here to see the POST HTML of the homepage</a><br />
<a href="?p=220" onclick="a('http://anthologyoi.com/index.php','p=220','hi'); return false;">Click here to see the GET HTML of the homepage</a><br />
 (they are the same)<br />
<textarea id="hi" rows="5" columns="5"></textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/short-ajax-script.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Custom Category Templates on a Archive or Index page.</title>
		<link>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html</link>
		<comments>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html#comments</comments>
		<pubDate>Wed, 23 Jan 2008 21:00:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[style]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html</guid>
		<description><![CDATA[On my home page and in my archives, I use a custom category template to display asides and news articles. This is very easy to do and it only takes a couple seconds of work to create custom category templates &#8230; <a href="http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On <a href="http://anthologyoi.com/">my home page</a> and in my archives, I use a custom category template to display <a href="http://anthologyoi.com/archive/blogish/asides">asides</a> and <a href="http://anthologyoi.com/archive/news-briefs">news</a> articles. This is very easy to do and it only takes a couple seconds of work to create custom category templates in any WordPress theme. </p>
<p>The first step is to add the following to your current theme&#8217;s index.php loop after the line that looks like <span class="inline-code">&lt;?php while (have_posts()) : the_post(); ?&gt;</span>, but before any other code.<br />
<pre class="brush: php">&lt;?php $cat_temp = cat_loop();?&gt;
	&lt;?php if($cat_temp &amp;&amp; is_numeric($cat_temp)){?&gt;
		&lt;?php include(&#039;loops/cat_&#039;.$cat_temp.&#039;.php&#039;);?&gt;
	&lt;?php }else{ ?&gt;</pre></p>
<p>Then add <span class="inline-code">}</span> just before the line <span class="inline-code">endwhile</span>.</p>
<p>The next step is to add the following to your theme&#8217;s functions.php file (you may have to create a file with the same name):</p>
<p><pre class="brush: php">function cat_loop(){
	global $blog_id,$post, $wp_version;
		if($wp_version &gt;= 2.3){
			global $object_term_cache;
			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];
		}else{
			global $category_cache;
			$array = $category_cache[$blog_id][$post-&gt;ID];
		}
		while (list($cat) = each($array)) {
			if(file_exists(dirname(__FILE__).&#039;/loops/cat_&#039;.$cat.&#039;.php&#039;)){
				return $cat;
			}
		}
	}</pre></p>
<p>This can be modified to look at author&#8217;s also. Now the only thing you have to do is to create a folder named &#8220;loops&#8221; in your theme&#8217;s folder, and then create a new file with a new &#8220;loop&#8221; &#8212; excluding the while and endwhile parts &#8212; and name it cat_xxx.php where xxx is the id of the category the loops is for. </p>
<p>This can be repeated for single.php, archive.php, or anywhere else a custom loop is useful. You can even use something similar for individual posts or pages.</p>
<p>A post may be in multiple categories, but it will only use the first custom template it finds, so make sure the post is in only one specially styled category at a time.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t connect to local MySQL server through socket&#8230;error.</title>
		<link>http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html</link>
		<comments>http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html#comments</comments>
		<pubDate>Fri, 21 Sep 2007 10:08:37 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/cant-connect-to-local-mysql-server-through-socketerror.html</guid>
		<description><![CDATA[I recently moved my /home folder to its own partition, but in doing so, I broke MySQL. The full error I got was: Can&#039;t connect to local MySQL server through socket &#039;/var/run/mysqld/mysqld.sock&#039; (2) To fix this you need to create &#8230; <a href="http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently moved my /home folder to its own partition, but in doing so, I broke MySQL. The full error I got was:<br />
<span class="inline-code">Can&#039;t connect to local MySQL server through socket &#039;/var/run/mysqld/mysqld.sock&#039; (2)</span></p>
<p>To fix this you need to create the file and make sure that MySQL has access to it. (All commands need to be run as root)</p>
<p>Create the directory (if it doesn&#8217;t already exist).</p>
<p><span class="inline-code">sudo mkdir /var/run/mysqld/</span></p>
<p>Create the file by &#8220;touching&#8221; it.</p>
<p><span class="inline-code">sudo touch /var/run/mysqld/mysqld.sock</span></p>
<p>Set the ownership of the mysqld.sock file and folder to mysql.</p>
<p><span class="inline-code">sudo chown -R mysql /var/run/mysqld/</span></p>
<p>You can then start MySQL and breath easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html/feed</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>DIY Javascript Effects Library</title>
		<link>http://anthologyoi.com/dev/diy-javascript-effects-library.html</link>
		<comments>http://anthologyoi.com/dev/diy-javascript-effects-library.html#comments</comments>
		<pubDate>Wed, 12 Sep 2007 10:00:34 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[cross browser]]></category>
		<category><![CDATA[effects library]]></category>
		<category><![CDATA[extensibility]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[special effects]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/dev/diy-javascript-effects-library.html</guid>
		<description><![CDATA[As part of a project I needed an extremely light-weight special effects library that would allow queuing of effects (required), multiple effects, the ability to set a per-effect &#8220;framerate&#8221;, and enough extensibility to fill any need, but it had to &#8230; <a href="http://anthologyoi.com/dev/diy-javascript-effects-library.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As part of a project I needed an extremely light-weight special effects library that would allow queuing of effects (required), multiple effects, the ability to set a per-effect &#8220;framerate&#8221;, and enough extensibility to fill any need, but it had to be independent of any Javascript library or OS.</p>
<p>For the &#8220;core&#8221;: I needed it to be able to queue effects to run one after another, but still be able to run effects synchronously with their own queues. Setting up the effects should take no more than a few lines, and the library should be easy adapted to the website or app it is currently running on. The library must also be cross browser, run well on lower end computers, and very very small (the main reason for creating it was as a replacement in a project for people who didn&#8217;t want to use jQuery or Scriptaculous just for the effects.) The core should be able to do everything with only being told the element&#8217;s ID, whether we are showing or hiding it (if applicable), and the effect to use. An added &#8220;feature&#8221; I wanted was something that could be used to create a tutorial, so no features could be used that were too fancy.</p>
<p>For the effects: I needed each individual effect to take no more than a few lines of setup, processing and finishing, so the framework needed to control everything, but each effect should be able to set its own duration using the framerate set. It should also be extremely simple to add new effects to the library.</p>
<p>The results: A library that is only 8KB in size (without compression or comments) or 2.9KB with natural (not gZip) compression and no comments with 4 built-in effects. While I&#8217;ll admit that the syntax to call effects isn&#8217;t as &#8220;pretty&#8221; as some of the other libraries, it is very simple, and queuing is powerful and easy to set up. If you want to jump ahead and see the finished product go <a href='http://anthologyoi.com/wp-content/uploads/2007/09/effects.js' title='Effects Library v1'>here</a></p>
<p>This is just a demonstration post. The actual code will be explained in the future.</p>
<p>To test the effects library click <a href="#test" id='test' onclick="AOI_eff.start('test_1', {'mode': 'show', 'eff': 'Expand', 'queue': ['hide::test_1::Fade','show::test_2::ScrollLeft::450','hide::test_2::ScrollLeft::50','show::test_1::Fade::25']} ); return false;">here</a></p>
<input type="button" style="display:none;" value="I'm test one" id="test_1"/>
<input type="button" style="display:none;" value="I'm test two" id="test_2"/>
<p>The that group of effects was done with the following code:<br />
<span class="inline-code">AOI_eff.start(&#039;test_1&#039;, {&#039;mode&#039;: &#039;show&#039;, &#039;eff&#039;: &#039;Expand&#039;, &#039;queue&#039;: [&#039;hide::test_1::Fade&#039;,&#039;show::test_2::ScrollLeft::450&#039;,&#039;hide::test_2::ScrollLeft::50&#039;,&#039;show::test_1::Fade::25&#039;]} );</span></p>
<p>Something a little more interesting: <a href="#test" id='test' onclick="AOI_eff.start('test_3', {'mode': 'show', 'eff': 'Expand', 'delay': 75, 'queue': ['show::test_4::Fade','show::test_5::ScrollLeft','show::test_6::SlideUp::50']} ); AOI_eff.start('test_5', {'mode': 'show', 'eff': 'Expand', 'delay': 75, 'queue': ['show::test_3::Fade']} );<br />
return false;">here</a> or the same thing, but with opposite displays  <a href="#test" id='test' onclick="AOI_eff.start('test_3', {'mode': 'hide', 'eff': 'Expand', 'delay': 75, 'queue': ['hide::test_4::Fade','hide::test_5::ScrollLeft','hide::test_6::SlideUp::50']} ); AOI_eff.start('test_5', {'mode': 'hide', 'eff': 'Expand', 'delay': 75, 'queue': ['hide::test_3::Fade']} );<br />
return false;">here</a> or the same thing, but the effects depend on the display. <a href="#test" id='test' onclick="AOI_eff.start('test_3', {'eff': 'Expand', 'delay': 75, 'queue': ['::test_4::Fade','::test_5::ScrollLeft','::test_6::SlideUp::50']} ); AOI_eff.start('test_5', {'eff': 'Expand', 'delay': 75, 'queue': ['::test_3::Fade']} );<br />
return false;">here</a></p>
<input type="button" style="display:none;" value="I'm test three" id="test_3"/>
<input type="button" style="display:none;" value="I'm test four" id="test_4"/>
<input type="button" style="display:block;" value="I'm test five" id="test_5"/>
<input type="button" style="display:none;" value="I'm test six" id="test_6"/>
<p>The onClick commands for those effects are, respectively, as follows.</p>
<p><pre class="brush: php">AOI_eff.start(&#039;test_3&#039;, {&#039;mode&#039;: &#039;show&#039;, &#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;show::test_4::Fade&#039;,&#039;show::test_5::ScrollLeft&#039;,&#039;show::test_6::SlideUp::50&#039;]} ); AOI_eff.start(&#039;test_5&#039;, {&#039;mode&#039;: &#039;show&#039;, &#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;show::test_3::Fade&#039;]} );
AOI_eff.start(&#039;test_3&#039;, {&#039;mode&#039;: &#039;hide&#039;, &#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;hide::test_4::Fade&#039;,&#039;hide::test_5::ScrollLeft&#039;,&#039;hide::test_6::SlideUp::50&#039;]} ); AOI_eff.start(&#039;test_5&#039;, {&#039;mode&#039;: &#039;hide&#039;, &#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;hide::test_3::Fade&#039;]} );
AOI_eff.start(&#039;test_3&#039;, {&#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;::test_4::Fade&#039;,&#039;::test_5::ScrollLeft&#039;,&#039;::test_6::SlideUp::50&#039;]} ); AOI_eff.start(&#039;test_5&#039;, {&#039;eff&#039;: &#039;Expand&#039;, &#039;delay&#039;: 75, &#039;queue&#039;: [&#039;::test_3::Fade&#039;]} );</pre></p>
<p>As you can see this is still a work in progress, but I think over time it will improve greatly.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/diy-javascript-effects-library.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP include ladder to find include path.</title>
		<link>http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html</link>
		<comments>http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html#comments</comments>
		<pubDate>Mon, 10 Sep 2007 20:24:04 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[ladder]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[relative path]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/php-include-ladder-to-find-include-path.html</guid>
		<description><![CDATA[I needed a way to be able to include particular files from files that are themselves included. because the working directory was not necessarily the same, so I needed a way to find what the actual include path should be. &#8230; <a href="http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed a way to be able to include particular files from files that are themselves included. because the working directory was not necessarily the same, so I needed a way to find what the actual include path should be. The following code snippet finds a specific folder or file and returns the ladder (relative path) to get to it. </p>
<p><pre class="brush: php">function find_path($loc,$dir=0){
	for($i = 0; $i &lt; 10; $i++){
		if($dir){
			if(is_dir($ladder.$loc)){
				return $ladder;
				break;
			}
		}elseif(is_file($ladder.$loc)){
			return $ladder;
			break;
		}
		$ladder .=&#039;../&#039;;
	}
}</pre></p>
<p>This code is NOT user-input safe: any checks you do should be hard coded otherwise you might as well just give out your passwords.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XHTML vs HTML: Round 2</title>
		<link>http://anthologyoi.com/dev/xhtml-vs-html-round-2.html</link>
		<comments>http://anthologyoi.com/dev/xhtml-vs-html-round-2.html#comments</comments>
		<pubDate>Wed, 05 Sep 2007 19:00:21 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[content type]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[xHTML]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/dev/xhtml-vs-html-round-2.html</guid>
		<description><![CDATA[When XHTML was first released nearly everyone, myself included, rushed headlong into it. Countless websites were shredded, old HTML code was stripped out and rebuilt using XHTML syntax under the watchful eye of the W3 validators. When it was over, &#8230; <a href="http://anthologyoi.com/dev/xhtml-vs-html-round-2.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When XHTML was first released nearly everyone, myself included, rushed headlong into it. Countless websites were shredded, old HTML code was stripped out and rebuilt using XHTML syntax under the watchful eye of the W3 validators. When it was over, the dust settled and, for a time, everyone tried to pretend HTML no longer existed &#8212; scorning those who had the audacity to still use HTML. </p>
<p>Time passed. People began realizing that XHTML wasn&#8217;t the save all and be all that it was supposed to be: some popular browsers (cough: IE) couldn&#8217;t even properly render its content type of <em>application/xhtml+xml</em>, so developers were stuck calling it XHTML and pretending that it was truly XHTML+XML, but they were really just dishing out HTML that was properly formatted. </p>
<p>This is not to say that the &#8220;XHTML rush&#8221; &#8482; was bad or that it didn&#8217;t advance technologies and the semantic nature of programming: it, with the help of CSS, helped to banish the hack and slash methods that were intrinsic in the 1990&#8242;s because people started realizing what each tag really meant and peer pressure abounded. In the end, however, all it did was make people aware of the rules that were already there, and in the process forced users to break other rules.</p>
<p>Finally the stigma of using semantically-correct HTML, inside the industry, is wearing off (although outside of it XHTML is still a buzz-word) and developers are realizing that XHTML wasn&#8217;t really <em>the</em> thing to use&#8212;instead it was just a good, clean language to use when it was needed, and some are slowly trickling back to serving just plain-ol&#8217; HTML&#8212; albeit it this time with clean markup and remembering the lessons XHTML taught us.</p>
<p>Well it is on the verge of happening again: X/HTML 5.0 and XHTML 2.0 are both in development, and they both are trying to make their own mark on the browser space, but in the process they are just going to cause more trouble because the last time the (X)/HTML wars began XHTML 1.0 was, on the surface, HTML 4.0 with a few more rules. However, this time they are trying to go in separate directions, and the problem is that they both are doing some things correctly. (If you haven&#8217;t been keeping up with developments and want to read a comparison on what is and is not being done correctly read xhtml.com&#8217;s  <a href="http://xhtml.com/en/future/x-html-5-versus-xhtml-2/">X/HTML 5 Versus XHTML 2</a>) </p>
<p>While the competition will be good, in some ways, and the professionals will reason out the best language to use and why, the fame wars are going to start up again, so  be ready for it and get out your favorite fan-boy insults because only one language is going to survive.</p>
<p>This rant was brought to you by the letter <strong>X</strong> and the number <strong>3</strong>. Oh and in case you are wondering, this site is perfectly valid XHTML using the XHTML 1.1 DTD being served as text/html with .html extension.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/xhtml-vs-html-round-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysql Search and Replace.</title>
		<link>http://anthologyoi.com/wordpress/mysql-search-and-replace.html</link>
		<comments>http://anthologyoi.com/wordpress/mysql-search-and-replace.html#comments</comments>
		<pubDate>Fri, 31 Aug 2007 06:53:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/mysql-search-and-replace.html</guid>
		<description><![CDATA[I&#8217;ve been getting ready for WordPress 2.3, so in preparation I&#8217;ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I&#8217;ve used several different methods of separating words: all spaces, &#8230; <a href="http://anthologyoi.com/wordpress/mysql-search-and-replace.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been getting ready for WordPress 2.3, so in preparation I&#8217;ve started cleaning up my database. My first order of business was to clean up the tags database. Over time I&#8217;ve used several different methods of separating words: all spaces, hyphens and underscores have all been used which really makes the nice names ugly. Fixing this was easy, I just used the MYSQL replace command:</p>
<p><span class="inline-code">UPDATE `table` SET `field` = REPLACE(Field,&#039;change_me&#039;,&#039;to_me&#039;);</span></p>
<p>Or specifically for the tags:</p>
<p><span class="inline-code">UPDATE `wp_tags` SET `tag` = REPLACE(tag,&#039;_&#039;,&#039; &#039;);</span></p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/mysql-search-and-replace.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Designing flexible WordPress themes.</title>
		<link>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html</link>
		<comments>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html#comments</comments>
		<pubDate>Wed, 29 Aug 2007 07:07:43 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[custom templates]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/dev/theme-designers-code-less-do-more.html</guid>
		<description><![CDATA[The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most &#8230; <a href="http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The average WordPress theme has different files for pages, single posts, archives and the front page; however, most of them are almost exactly the same except for inside the_loop. This is a quick tutorial on how to do the most with the fewest files, and includes a few methods to have custom templates by separating content display from structural elements.</p>
<p>WordPress looks first for special files and then defaults to the index.php file (<a href="http://wpbits.wordpress.com/2007/08/22/making-wordpress-themes-iii-template-hierarchy/">as shown in this diagram</a>). We can take advantage of this by using only an index.php file and then using conditionals to modify it. While it seems that this method would render the code less readable, it is actually far more readable, and far easier to modify.</p>
<p>Your theme should start off a header.php, footer.php, sidebar.php and an index.php. These files are <a href="http://kahi.cz/wordpress/template-structure-graphically-clearly/">the &#8220;code&#8221; files</a> and are fairly self-explanatory, and at this point the only question should be whether you add just the header portion of the file to the header.php or everything including the calls to get_sidebar()&#8212;the same goes for the footer.php depending on your theme. This depends on how you use your them, if you plan to integrate it with bbPress and use the same header and sidebars, you should add everything before the normal loop to the header. However, we will focus on things outside of the header (this includes the navigation menus and such) and just focus on <a href="http://codex.wordpress.org/the_loop">the_loop</a>.</p>
<p>A &#8220;normal&#8221; index page looks a little like this. (Taken from the default WordPress theme.)</p>
<p><pre class="brush: php">&lt;?php get_header(); ?&gt;

	&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt;

	&lt;?php if (have_posts()) : ?&gt;

		&lt;?php while (have_posts()) : the_post(); ?&gt;

			&lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;
				&lt;h2&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
				&lt;small&gt;&lt;?php the_time(&#039;F jS, Y&#039;) ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt;

				&lt;div class=&quot;entry&quot;&gt;
					&lt;?php the_content(&#039;Read the rest of this entry &amp;raquo;&#039;); ?&gt;
				&lt;/div&gt;

				&lt;p class=&quot;postmetadata&quot;&gt;Posted in &lt;?php the_category(&#039;, &#039;) ?&gt; | &lt;?php edit_post_link(&#039;Edit&#039;, &#039;&#039;, &#039; | &#039;); ?&gt;  &lt;?php comments_popup_link(&#039;No Comments &amp;#187;&#039;, &#039;1 Comment &amp;#187;&#039;, &#039;% Comments &amp;#187;&#039;); ?&gt;&lt;/p&gt;
			&lt;/div&gt;

		&lt;?php endwhile; ?&gt;

		&lt;div class=&quot;navigation&quot;&gt;
			&lt;div class=&quot;alignleft&quot;&gt;&lt;?php next_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
			&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
		&lt;/div&gt;

	&lt;?php else : ?&gt;

		&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;
		&lt;p class=&quot;center&quot;&gt;Sorry, but you are looking for something that isn&#039;t here.&lt;/p&gt;
		&lt;?php include (TEMPLATEPATH . &quot;/searchform.php&quot;); ?&gt;

	&lt;?php endif; ?&gt;

	&lt;/div&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;</pre></p>
<p>For most themes, the page and single pages look the same: the only part that really changes is the_loop itself, and even then the changes are usually minor, so if you want to change something outside the_loop, you have to change it in all files. However, by operating the majority of display elements out of the main files, we can make it infinitely extensible without overloading the end-user with large amounts of code to sort through.</p>
<p>The index.php file for the theme I use is very short and easily read.</p>
<p><pre class="brush: php">&lt;?php get_header(); ?&gt;
	&lt;div id=&quot;wrap&quot;&gt;

		&lt;div id=&quot;content&quot;&gt;

			&lt;?php if (have_posts()) : ?&gt;

				&lt;?php
					if(is_home()){

						include (TEMPLATEPATH . &#039;/index-loop.php&#039;);

					}elseif(is_page() || is_single()){

						include (TEMPLATEPATH . &#039;/single-loop.php&#039;);

					}else{

						include (TEMPLATEPATH . &#039;/archive-loop.php&#039;);

					}
				?&gt;

			&lt;?php else :?&gt;
				&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;
				&lt;?php include (TEMPLATEPATH . &#039;/not-found.php&#039;);?&gt;
			&lt;?php endif; ?&gt;

		&lt;/div&gt;

		&lt;?php get_sidebar(); ?&gt;

	&lt;/div&gt;

&lt;?php get_footer(); ?&gt;</pre></p>
<p>If we break it down: it calls the header, adds the two structural divs, and checks to see if there are any posts (of any kind). If there are no posts it includes an error page before including the sidebar, closing the divs and calling the footer. This part of the page is fairly normal and is used in most themes&#8212;not only is it used in most themes, but most of the main files all have this same code&#8211;every single theme file calls the footer, sidebar and header, shows an error message if there are no posts to display. This is a lot of wasted space. If you suddenly want to change the name of something or move the sidebars, you have to change every file which is just pointless. The difference in my index.php file is that there isn&#8217;t a full loop. It checks if there are posts using have_posts(), but where you would normally see a loop it just has some <a href="http://codex.wordpress.org/Conditional_Tags">conditional statements</a>, and for each condition, a different loop is included. </p>
<p>Each of the loops is in a different included file. (The loops are shown below, but just notice the similarities and major differences.)</p>
<p>Index loop:</p>
<p><pre class="brush: php">&lt;?php while (have_posts()) : the_post(); ?&gt;
		&lt;h2 id=&quot;post-&lt;?php the_ID(); ?&gt;&quot; class=&quot;b&quot;&gt;
			&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt; &lt;/a&gt;
		&lt;/h2&gt;

		&lt;div class=&quot;main main_border&quot;&gt;

			&lt;small&gt;
				Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l \t\h\e jS \o\f F, Y \a\t g:i a &#039;) ?&gt; in &lt;?php the_category(&#039;, &#039;) ?&gt; &lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;
			&lt;/small&gt;

				&lt;?php the_content(&#039;Continue reading &quot;&#039;.the_title(&#039;&#039;, &#039;&#039;, false).&#039;&quot;&#039;)?&gt;

			&lt;div class=&quot;small box&quot;&gt;
				//Some comment and UTW stuff				
			&lt;/div&gt;	
		&lt;/div&gt;
&lt;?php endwhile; ?&gt;

&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
	&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:49%;&quot;&gt;&lt;?php posts_nav_link(&#039;&#039;,&#039;&#039;,&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
	&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:49%; text-align:right;&quot;&gt;&lt;?php posts_nav_link(&#039;&#039;,&#039;Next Entries &amp;raquo;&#039;,&#039;&#039;) ?&gt;&lt;/div&gt;
&lt;/div&gt;</pre></p>
<p>single-loop.php (handles both singles and pages because there is only a tiny difference between the two)</p>
<p><pre class="brush: php">&lt;?php while (have_posts()) : the_post(); ?&gt;

	&lt;h2&gt;&lt;?php the_title();?&gt;&lt;/h2&gt;


	&lt;small&gt;
		&lt;?php if(!is_page()){ /*Only difference between pages and singles*/?&gt;

			Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l \t\h\e jS \o\f F, Y \a\t g:i a &#039;) ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;in &lt;?php the_category(&#039;, &#039;) ?&gt; &lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;

		&lt;?php }else{?&gt;

			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;

		&lt;?php } ?&gt;
	&lt;/small&gt;

	&lt;div class=&quot;main&quot;&gt;

		&lt;?php the_content(&#039;Read the rest of this entry &amp;raquo;&#039;); ?&gt;

		&lt;?php wp_link_pages(); ?&gt;

		&lt;div class=&quot;small box&quot;&gt;

			//some comment and UTW stuff

		&lt;/div&gt;

		&lt;?php posts_nav_link(&#039; &amp;#8212; &#039;, __(&#039;&amp;laquo; Previous Page&#039;), __(&#039;Next Page &amp;raquo;&#039;)); ?&gt;

	&lt;/div&gt;

&lt;?php endwhile; ?&gt;</pre></p>
<p>And the archive-loop.php which handles categories, date archives, tags, searches etc.</p>
<p><pre class="brush: php">&lt;?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?&gt;

	&lt;?php /* If this is a category archive */ if (is_category()) { ?&gt;

		&lt;h2&gt; Reading about &lt;?php single_cat_title(); ?&gt;&lt;/h2&gt;

 	&lt;?php /* If this is a daily archive */ } elseif (is_day()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F jS, Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a monthly archive */ } elseif (is_month()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F, Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a yearly archive */ } elseif (is_year()) { ?&gt;

		&lt;h2&gt;Archive for &lt;?php the_time(&#039;Y&#039;); ?&gt;&lt;/h2&gt;

	&lt;?php /* If this is a search */ } elseif (is_search()) { ?&gt;

		&lt;h2&gt;The Search Results For &quot;&lt;?php echo $s;?&gt;&quot;&lt;/h2&gt;

	&lt;?php /* If this is an author archive */ } elseif (is_author()) { ?&gt;

		&lt;h2&gt;Author Archive&lt;/h2&gt;

	&lt;?php /* If this is a paged archive */ } elseif (isset($_GET[&#039;paged&#039;]) &amp;&amp; !empty($_GET[&#039;paged&#039;])) { ?&gt;

		&lt;h2&gt;Archives&lt;/h2&gt;

	&lt;?php } ?&gt;


	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
		&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:40%; text-align:right;&quot;&gt;&lt;?php next_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
	&lt;/div&gt;


	&lt;?php while (have_posts()) : the_post(); ?&gt;

	&lt;h3 class=&quot;b&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link a &lt;?php the_title(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h3&gt;

	&lt;div class=&quot;main main_border &lt;?php echo anth::styles();?&gt;&quot;&gt;

		&lt;small&gt;
			&lt;!-- Posted &lt;?php the_time(&#039;j F Y&#039;) ?&gt;  by &lt;?php the_author() ?&gt; --&gt;
			&lt;?php if(function_exists(&#039;UTW_ShowTagsForCurrentPost&#039;)){?&gt;
				&lt;span class=&quot;utwtags&quot;&gt;Keywords: &lt;?php UTW_ShowTagsForCurrentPost(&quot;commalist&quot;) ?&gt;&lt;/span&gt;
			&lt;?php } ?&gt;
			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;
		&lt;/small&gt;

			&lt;?php the_excerpt() ?&gt;

	&lt;/div&gt;

&lt;?php endwhile; ?&gt;

&lt;br/&gt;

	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;
		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&amp;laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
		&lt;div class=&quot;main-nav-right&quot; style=&quot;float:right;width:40%; text-align:right;&quot;&gt;&lt;?php next_posts_link(&#039;Next Entries &amp;raquo;&#039;) ?&gt;&lt;/div&gt;
	&lt;/div&gt;</pre></p>
<p>The actual loops in each of these files starts with <span class="inline-code">&lt;?php while (have_posts()) : the_post(); ?&gt;</span>, and you will notice that all the loops are similar with only a few cosmetic changes, the major difference is in the archive page which uses a large conditional block to set the title text, but this could have been done on the index.php page and used a completely different loop if you needed it.</p>
<p>Okay, so you get down to here and wonder why you haven&#8217;t heard anything new. well once we start using custom loops the possibilities are endless.</p>
<p>For example, as <a href="http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html">I posted about recently</a>, on my index I use a special loop for items that are in the <a href="http://anthologyoi.com/archive/blogish/asides/">Asides category</a>, but only on the index page, so inside of my is_home) conditional statement I also add the code:</p>
<p><pre class="brush: php">&lt;?php $in_cat = cat_loop();?&gt;
	&lt;?php if($in_cat){?&gt;
		&lt;?php include(&#039;cat_&#039;.$in_cat.&#039;.php&#039;);?&gt;
	&lt;?php } ?&gt;</pre></p>
<p>Which calls the function: (added to the functions.php file)<br />
<pre class="brush: php">function cat_loop(){
	global $blog_id,$post, $wp_version;
		if($wp_version &gt;= 2.3){
			global $object_term_cache;
			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];
		}else{
			global $category_cache;
			$array = $category_cache[$blog_id][$post-&gt;ID];
		}
		while (list($cat) = each($array)) {
			if(file_exists(dirname(__FILE__).&#039;/cat_&#039;.$cat.&#039;.php&#039;)){
				return $cat;
			}
		}
	}</pre></p>
<p>Basically the function loops through all the categories a post is in and if there is a custom loop for a category it uses it. This can easily be extended for author ids, name or anything else that you can test.</p>
<p>Let&#8217;s review: use as little repeated code as possible because when you do lots of tricks are available to you. </p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generating Semantic Comment Lists with XHTML</title>
		<link>http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html</link>
		<comments>http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html#comments</comments>
		<pubDate>Wed, 22 Aug 2007 07:46:49 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[formating]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[symantic]]></category>
		<category><![CDATA[xHTML]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/dev/generating-symantic-comment-lists-with-xhtml.html</guid>
		<description><![CDATA[XHTML specifications provide three types of lists ordered lists &#60;ol>, unordered lists &#60;ul> and definition lists &#60;dl>. Ordered lists are meant for content that must be arranged in a specific order &#8212; things like instructions, or lines of code. Unordered &#8230; <a href="http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>XHTML specifications provide three types of lists ordered lists &lt;ol>, unordered lists &lt;ul> and definition lists &lt;dl>. Ordered lists are meant for content that must be arranged in a specific order &#8212; things like instructions, or lines of code. Unordered lists are meant to be used for content that can reasonably be displayed in any order such as navigation menus or shopping lists. The rarely used definition lists is meant to be used where one list item is logically defined by a subsequent item (a definition term &lt;dt> followed by a definition description &lt;dd>) it functions the same way as a FAQ or glossary. However, when specifically used for comments, the only sure bet is that the unordered list is inappropriate &#8212; because comments require a specific order to make sense &#8212; while the ordered list and definition list vie for being the second worst. (Note I didn&#8217;t say best because neither is really qualified.) So this post will try to iron out the argument a bit.</p>
<p>Some things the remember: all lists are block level elements which means they can contain almost any other element and still retain validity.</p>
<h3>Definition lists</h3>
<p>Definition lists do not seem to be the appropriate element because a comment is not strictly a definition, however, if you take the W3C&#8217;s name for the dd element, (definition description) it appears that it could also be used for comment lists. Structurally, however, the definition list fits perfectly with the standard comment.<br />
<code title="Comment List example"></p>
<dl>
<dt>John posted the following on 12/9/2007</dt>
<dd>
<p>Wow, what a great list example.</p>
</dd>
<dt>Aaron posted the following on 13/9/2007</dt>
<dd>
<p>Why thank you.</p>
</dd>
<dt>John posted the following on 12/9/2007</dt>
<dd>
<p>You are very welcome. The list is flawless.</p>
</dd>
</dl>
<p>[/sourcecode]</p>
<p>Wow, that is almost perfect. The commenter's information is the term and the thoughts are described in the comment. it is almost too perfect, and here is where it breaks down. </p>
<p>1) Structurally, and semantically you can't have the comment on top and the author's information on the bottom. The following is just a pile of invalid tags. It has no semantic meaning, unless you are playing a game of jeopardy, and structurally it is invalid.</p>
<p><code title="Comment List example"></p>
<dl>
<dd>
<p>Wow, what a great list example.</p>
</dd>
<dt>John posted the above on 12/9/2007</dt>
<dd>
<p>Why thank you.</p>
</dd>
<dt>Aaron posted the above on 13/9/2007</dt>
<dd>
<p>You are very welcome. The list is flawless.</p>
</dd>
<dt>John posted the above on 12/9/2007</dt>
</dl>
<p>[/sourcecode]</p>
<p>2) You can't logically nest &lt;dt>/&lt;dd> combinations inside each other, so you can't have threaded comments.</p>
<p>3) The use of &lt;dt> tags to hold citation information is sketchy at best, although the &lt;dd> tag is defined as a description, it is rather a stretch to ignore the definiton part of it. </p>
<p>4) Thee is nothing in the standards that require terms to be in a specific order.</p>
<p>So it isn't possible to use &lt;dl>'s and still retain both structural and semantic validity. However, we do know that comments are a list, so this just leaves unordered lists.</p>
<h3>Ordered Lists</h3>
<p>If your comments are "flat" (only one level of comments, no parent/children pairs)  then the ordered list seems to make the most sense if you want numbers to be automatically generated. However, for sites that allow threading, like this one, the numbers must be hidden.</p>
<p>Now in a typical comment list we have:</p>
<p><code title="Comment List example"></p>
<ol>
<li>
<div>John posted the following on 12/9/2007</div>
<div>
<p>Wow, what a great list example.</p>
</div>
</li>
<li>
<div>Aaron posted the following on 13/9/2007</div>
<div>
<p>Why thank you.</p>
</div>
</li>
<li>
<div>John posted the following on 12/9/2007</div>
<div>
<p>You are very welcome. The list is flawless.</p>
</div>
</li>
</ol>
<p>[/sourcecode]</p>
<p>The greatest strength of using the ordered list is it nests flawlessly: </p>
<p><code title="Comment List example"></p>
<ol>
<li>
<div>John posted the following on 12/9/2007</div>
<div>
<p>Wow, what a great list example.</p>
</div>
<ol>
<li>
<div>Aaron posted the following on 13/9/2007</div>
<div>
<p>Why thank you.</p>
</div>
<ol>
<li>
<div>John posted the following on 12/9/2007</div</p>
<div>
<p>You are very welcome. The list is flawless.</p>
</div>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<p>[/sourcecode]</p>
<p>Although the markup by hand can appear to be a little convoluted, it is a perfect nested list and semantically it demonstrates inheritance and means  exactly what we want it to mean. Now the problem with this, is that semantically the content of the &lt;li>'s don't have any meaning even though the relationship between the two items is defined by using an ordered list. To create a semantically valid ordered list we can replace the two divs with elements that are a little more semantic.</p>
<p><code title="Comment List example"></p>
<ol>
<li>
		<cite>John posted the following on 12/9/2007</cite></p>
<blockquote><p>Wow, what a great list example.</p>
</blockquote>
</li>
<li>
		<cite>Aaron posted the following on 13/9/2007</cite></p>
<blockquote><p>Why thank you.</p>
</blockquote>
</li>
<li>
		<cite>John posted the following on 12/9/2007</cite></p>
<blockquote><p>You are very welcome. The list is flawless.</p>
</blockquote>
</li>
</ol>
<p>[/sourcecode]</p>
<p>Now this version is better: The cite tag works because it is not only citing the person who said it but also <em>when</em> they said it, and no meaning is lost if you move the cite tag below the blockquote, but I think the blockquote may be inappropriate because while the person is saying it, we aren't quoting them.  However if in the example were quoted in the second, the blockquote would be appropriate (although we can ignore the fact that the &lt;q> would have been more appropriate.)  </p>
<p>Now because I hate to introduce presentational elements back into it, I think that if there <em>needs</em> to be an element wrapping the content of the comment, it should be a blockquote because yes technically it is a quote and if the page were to appear in a print edition it would be treated as a quote, but I don't think it isn't seen that way by most people.</p>
<p> However, we still need to format the content inside the li a little better. The previous example gets it almost correct, but the cite element really is being used incorrectly.</p>
<p><code title="Comment List example"></p>
<ol>
<li>
<p><cite>John</cite> posted the following on 12/9/2007</p>
<p>Wow, what a great list example.</p>
</li>
<li>
<p><cite>Aaron</cite> posted the following on 13/9/2007</p>
<p>Why thank you.</p>
</li>
<li>
<p><cite>John</cite> posted the following on 13/9/2007</p>
<p>You are very welcome. The list is flawless.</p>
</li>
</ol>
<p>[/sourcecode]</p>
<p>Much better, theoretically we could be using a &lt;span> tag instead of a &lt;p> tag, but we would have to put the &lt;span> inside of a &#038;ltp> anyway, and with the addition to style information to the &lt;p> tag containing the author information, the content will be both symantically and structurally valid.  As a final note, although  I ragged on using structural elements quite a lot, but they aren't always bad. I do use them on this site to wrap single comments when needed (because comments are nested, so a style applied to one comment applies to all.)</p>
<p>So what did we learn here?</p>
<ol>
<li> Ordered lists should always be used for comments (but dl lists may be valid for other types of dialog)</li>
<li>&lt;div>'s and &lt;span>'s should never be used to hold comment information because there are elements that are much better suited to it.</li>
<li>If you need a block level element to hold your comment text, use a &lt;blockquote> it may require a little extra effort to style correctly, but it is always better to do things the right way.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

