<?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>Anthology of Ideas &#187; Dev</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>Thu, 24 Nov 2011 19:07:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=insert-an-image-into-a-wordpress-post-with-a-plugin</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[Dev]]></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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>	include_once(ABSPATH.&#039;/wp-admin/includes/media.php&#039;);</code></li><li><code>	include_once(ABSPATH.&#039;/wp-admin/includes/file.php&#039;);</code></li><li class="alt"><code>	include_once(ABSPATH.&#039;/wp-admin/includes/image.php&#039;);</code></li><li><code>	</code></li><li class="alt"><code>//	$id is the id of the post being inserted</code></li><li><code>//	$name is actually the name of the form input that uploaded the file so WP can access it using $_FILE[$name]</code></li><li class="alt"><code>	media_handle_upload($name,$id);</code></li></ol>
<p>If you are inserting a new post, it makes sense to have the line <span class='code_child' style='display:; padding:4px;'>$id = wp_insert_post($post_data);</span> before this.</p>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Del.icio.us" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to digg" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Insert+an+image+into+a+WordPress+Post+with+a+plugin.&amp;u=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to FURL" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to reddit" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Technorati" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Stumble Upon" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Google Bookmarks" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/insert-an-image-into-a-wordpress-post-with-a-plugin.html&amp;title=Insert+an+image+into+a+WordPress+Post+with+a+plugin." title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Co.mments" alt="Add &#039;Insert an image into a WordPress Post with a plugin.&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=short-ajax-script</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[Dev]]></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 resulting AJAX scripts, the post version is 410 characters and the GET version is only [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://anthologyoi.com/wp-content/plugins/photo_dropper/images/loading.gif" alt="" style="float:left; padding:10px;"/> 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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>function a(l,d,u){</code></li><li><code>try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}</code></li><li class="alt"><code>if(r){</code></li><li><code>r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}</code></li><li class="alt"><code>r.open(&#039;GET&#039;, l+&#039;?&#039;+d, true);r.send(d);</code></li><li><code>}</code></li><li class="alt"><code>}</code></li></ol>
<h3>&#8220;Post&#8221; AJAX Script</h3>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>function b(l,d,u){</code></li><li><code>try{r = new XMLHttpRequest();} catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);} catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}</code></li><li class="alt"><code>if(r){</code></li><li><code>r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML=r.responseText;}}</code></li><li class="alt"><code>r.open(&#039;POST&#039;, l, true);r.setRequestHeader(&#039;Content-type&#039;, &#039;application/x-www-form-urlencoded&#039;);r.send(d);</code></li><li><code>}</code></li><li class="alt"><code>}</code></li></ol>
<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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>function a(l,d,u,p){</code></li><li><code>try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}</code></li><li class="alt"><code>if(r){</code></li><li><code>r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}</code></li><li class="alt"><code>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);}</code></li><li><code>}</code></li><li class="alt"><code>}</code></li></ol>
<p>Demo: (Sorry but you will have to go to the full page so the JavaScript is loaded.)<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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Short Ajax Script&#039; to Del.icio.us" alt="Add &#039;Short Ajax Script&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Short Ajax Script&#039; to digg" alt="Add &#039;Short Ajax Script&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Short+Ajax+Script&amp;u=http://anthologyoi.com/dev/short-ajax-script.html" title="Add &#039;Short Ajax Script&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Short Ajax Script&#039; to FURL" alt="Add &#039;Short Ajax Script&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Short Ajax Script&#039; to reddit" alt="Add &#039;Short Ajax Script&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/short-ajax-script.html" title="Add &#039;Short Ajax Script&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Short Ajax Script&#039; to Technorati" alt="Add &#039;Short Ajax Script&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Short Ajax Script&#039; to Stumble Upon" alt="Add &#039;Short Ajax Script&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Short Ajax Script&#039; to Google Bookmarks" alt="Add &#039;Short Ajax Script&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/short-ajax-script.html&amp;title=Short+Ajax+Script" title="Add &#039;Short Ajax Script&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Short Ajax Script&#039; to Co.mments" alt="Add &#039;Short Ajax Script&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=custom-category-templates-on-a-archive-or-index-page</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[Dev]]></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 in any WordPress theme. The first step is to add the following to your current [...]]]></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='code_child' style='display:; padding:4px;'>&lt;?php while (have_posts()) : the_post(); ?&gt;</span>, but before any other code.</p>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php $cat_temp = cat_loop();?&gt;</code></li><li><code>	&lt;?php if($cat_temp &amp;&amp; is_numeric($cat_temp)){?&gt;</code></li><li class="alt"><code>		&lt;?php include(&#039;loops/cat_&#039;.$cat_temp.&#039;.php&#039;);?&gt;</code></li><li><code>	&lt;?php }else{ ?&gt;</code></li></ol>
<p>Then add <span class='code_child' style='display:; padding:4px;'>}</span> just before the line <span class='code_child' style='display:; padding:4px;'>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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>	function cat_loop(){</code></li><li><code>	global $blog_id,$post, $wp_version;</code></li><li class="alt"><code>		if($wp_version &gt;= 2.3){</code></li><li><code>			global $object_term_cache;</code></li><li class="alt"><code>			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];</code></li><li><code>		}else{</code></li><li class="alt"><code>			global $category_cache;</code></li><li><code>			$array = $category_cache[$blog_id][$post-&gt;ID];</code></li><li class="alt"><code>		}</code></li><li><code>		while (list($cat) = each($array)) {</code></li><li class="alt"><code>			if(file_exists(dirname(__FILE__).&#039;/loops/cat_&#039;.$cat.&#039;.php&#039;)){</code></li><li><code>				return $cat;</code></li><li class="alt"><code>			}</code></li><li><code>		}</code></li><li class="alt"><code>	}</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>	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;
			}
		}
	}</textarea></li></ol>
<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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Del.icio.us" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to digg" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Custom+Category+Templates+on+a+Archive+or+Index+page.&amp;u=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to FURL" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to reddit" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Technorati" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Stumble Upon" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Google Bookmarks" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/wordpress/custom-category-templates-on-a-archive-or-index-page.html&amp;title=Custom+Category+Templates+on+a+Archive+or+Index+page." title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Co.mments" alt="Add &#039;Custom Category Templates on a Archive or Index page.&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cant-connect-to-local-mysql-server-through-socketerror</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[Dev]]></category>
		<category><![CDATA[Linux]]></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 the file and make sure that MySQL has access to it. (All commands need to [...]]]></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='code_child' style='display:block; padding:4px;'>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>
<span class='code_child' style='display:; padding:4px;'>sudo mkdir /var/run/mysqld/</span>
<p>Create the file by &#8220;touching&#8221; it.</p>
<span class='code_child' style='display:; padding:4px;'>sudo touch /var/run/mysqld/mysqld.sock</span>
<p>Set the ownership of the mysqld.sock file and folder to mysql.</p>
<span class='code_child' style='display:; padding:4px;'>sudo chown -R mysql /var/run/mysqld/</span>
<p>You can then start MySQL and breath easier.</p>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Del.icio.us" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to digg" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror.&amp;u=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to FURL" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to reddit" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Technorati" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Stumble Upon" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Google Bookmarks" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html&amp;title=Can%26%238217%3Bt+connect+to+local+MySQL+server+through+socket%26%238230%3Berror." title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Co.mments" alt="Add &#039;Can&amp;#8217;t connect to local MySQL server through socket&amp;#8230;error.&#039; to Co.mments" />
</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/computers/cant-connect-to-local-mysql-server-through-socketerror.html/feed</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>DIY Javascript Effects Library</title>
		<link>http://anthologyoi.com/dev/diy-javascript-effects-library.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=diy-javascript-effects-library</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[Dev]]></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 be independent of any Javascript library or OS. For the &#8220;core&#8221;: I needed it to [...]]]></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='code_child' style='display:block; padding:4px;'>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 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 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</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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>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;]} );</code></li><li><code>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;]} );</code></li><li class="alt"><code>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;]} );  </code></li></ol>
<p>As you can see this is still a work in progress, but I think over time it will improve greatly.</p>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;DIY Javascript Effects Library&#039; to Del.icio.us" alt="Add &#039;DIY Javascript Effects Library&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;DIY Javascript Effects Library&#039; to digg" alt="Add &#039;DIY Javascript Effects Library&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=DIY+Javascript+Effects+Library&amp;u=http://anthologyoi.com/dev/diy-javascript-effects-library.html" title="Add &#039;DIY Javascript Effects Library&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;DIY Javascript Effects Library&#039; to FURL" alt="Add &#039;DIY Javascript Effects Library&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;DIY Javascript Effects Library&#039; to reddit" alt="Add &#039;DIY Javascript Effects Library&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/diy-javascript-effects-library.html" title="Add &#039;DIY Javascript Effects Library&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;DIY Javascript Effects Library&#039; to Technorati" alt="Add &#039;DIY Javascript Effects Library&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;DIY Javascript Effects Library&#039; to Stumble Upon" alt="Add &#039;DIY Javascript Effects Library&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;DIY Javascript Effects Library&#039; to Google Bookmarks" alt="Add &#039;DIY Javascript Effects Library&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/diy-javascript-effects-library.html&amp;title=DIY+Javascript+Effects+Library" title="Add &#039;DIY Javascript Effects Library&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;DIY Javascript Effects Library&#039; to Co.mments" alt="Add &#039;DIY Javascript Effects Library&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-include-ladder-to-find-include-path</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[Dev]]></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. The following code snippet finds a specific folder or file and returns the ladder (relative [...]]]></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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>	</code></li><li><code>function find_path($loc,$dir=0){</code></li><li class="alt"><code>	for($i = 0; $i &lt;10; $i++){</code></li><li><code>		if($dir){</code></li><li class="alt"><code>			if(is_dir($ladder.$loc)){</code></li><li><code>				return $ladder;</code></li><li class="alt"><code>				break;</code></li><li><code>			}</code></li><li class="alt"><code>		}elseif(is_file($ladder.$loc)){</code></li><li><code>			return $ladder;</code></li><li class="alt"><code>			break;</code></li><li><code>		}</code></li><li class="alt"><code>		$ladder .=&#039;../&#039;;</code></li><li><code>	}</code></li><li class="alt"><code>}</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>	
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;;
	}
}</textarea></li></ol>
<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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;PHP include ladder to find include path.&#039; to Del.icio.us" alt="Add &#039;PHP include ladder to find include path.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;PHP include ladder to find include path.&#039; to digg" alt="Add &#039;PHP include ladder to find include path.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=PHP+include+ladder+to+find+include+path.&amp;u=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html" title="Add &#039;PHP include ladder to find include path.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;PHP include ladder to find include path.&#039; to FURL" alt="Add &#039;PHP include ladder to find include path.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;PHP include ladder to find include path.&#039; to reddit" alt="Add &#039;PHP include ladder to find include path.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html" title="Add &#039;PHP include ladder to find include path.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;PHP include ladder to find include path.&#039; to Technorati" alt="Add &#039;PHP include ladder to find include path.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;PHP include ladder to find include path.&#039; to Stumble Upon" alt="Add &#039;PHP include ladder to find include path.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;PHP include ladder to find include path.&#039; to Google Bookmarks" alt="Add &#039;PHP include ladder to find include path.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/php-include-ladder-to-find-include-path.html&amp;title=PHP+include+ladder+to+find+include+path." title="Add &#039;PHP include ladder to find include path.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;PHP include ladder to find include path.&#039; to Co.mments" alt="Add &#039;PHP include ladder to find include path.&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xhtml-vs-html-round-2</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[Dev]]></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, the dust settled and, for a time, everyone tried to pretend HTML no longer existed [...]]]></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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to Del.icio.us" alt="Add &#039;XHTML vs HTML: Round 2&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to digg" alt="Add &#039;XHTML vs HTML: Round 2&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=XHTML+vs+HTML%3A+Round+2&amp;u=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html" title="Add &#039;XHTML vs HTML: Round 2&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to FURL" alt="Add &#039;XHTML vs HTML: Round 2&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to reddit" alt="Add &#039;XHTML vs HTML: Round 2&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html" title="Add &#039;XHTML vs HTML: Round 2&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to Technorati" alt="Add &#039;XHTML vs HTML: Round 2&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to Stumble Upon" alt="Add &#039;XHTML vs HTML: Round 2&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to Google Bookmarks" alt="Add &#039;XHTML vs HTML: Round 2&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/xhtml-vs-html-round-2.html&amp;title=XHTML+vs+HTML%3A+Round+2" title="Add &#039;XHTML vs HTML: Round 2&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;XHTML vs HTML: Round 2&#039; to Co.mments" alt="Add &#039;XHTML vs HTML: Round 2&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-search-and-replace</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[Dev]]></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, hyphens and underscores have all been used which really makes the nice names ugly. Fixing [...]]]></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>
<span class='code_child' style='display:block; padding:4px;'>UPDATE `table` SET `field` = REPLACE(Field,&#039;change_me&#039;,&#039;to_me&#039;);</span>
<p>Or specifically for the tags:</p>
<span class='code_child' style='display:block; padding:4px;'>UPDATE `wp_tags` SET `tag` = REPLACE(tag,&#039;_&#039;,&#039; &#039;);</span>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Mysql Search and Replace.&#039; to Del.icio.us" alt="Add &#039;Mysql Search and Replace.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Mysql Search and Replace.&#039; to digg" alt="Add &#039;Mysql Search and Replace.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Mysql+Search+and+Replace.&amp;u=http://anthologyoi.com/wordpress/mysql-search-and-replace.html" title="Add &#039;Mysql Search and Replace.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Mysql Search and Replace.&#039; to FURL" alt="Add &#039;Mysql Search and Replace.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Mysql Search and Replace.&#039; to reddit" alt="Add &#039;Mysql Search and Replace.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/wordpress/mysql-search-and-replace.html" title="Add &#039;Mysql Search and Replace.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Mysql Search and Replace.&#039; to Technorati" alt="Add &#039;Mysql Search and Replace.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Mysql Search and Replace.&#039; to Stumble Upon" alt="Add &#039;Mysql Search and Replace.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Mysql Search and Replace.&#039; to Google Bookmarks" alt="Add &#039;Mysql Search and Replace.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/wordpress/mysql-search-and-replace.html&amp;title=Mysql+Search+and+Replace." title="Add &#039;Mysql Search and Replace.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Mysql Search and Replace.&#039; to Co.mments" alt="Add &#039;Mysql Search and Replace.&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=designing-flexible-wordpress-themes</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[Dev]]></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 with the fewest files, and includes a few methods to have custom templates by separating [...]]]></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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php get_header(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;div id=&quot;content&quot; class=&quot;narrowcolumn&quot;&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;?php if (have_posts()) : ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;?php while (have_posts()) : the_post(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>			&lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;</code></li><li><code>				&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;</code></li><li class="alt"><code>				&lt;small&gt;&lt;?php the_time(&#039;F jS, Y&#039;) ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt;</code></li><li><code>	</code></li><li class="alt"><code>				&lt;div class=&quot;entry&quot;&gt;</code></li><li><code>					&lt;?php the_content(&#039;Read the rest of this entry &raquo;&#039;); ?&gt;</code></li><li class="alt"><code>				&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>				&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 &raquo;&#039;, &#039;1 Comment &raquo;&#039;, &#039;% Comments &raquo;&#039;); ?&gt;&lt;/p&gt;</code></li><li><code>			&lt;/div&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;?php endwhile; ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;div class=&quot;navigation&quot;&gt;</code></li><li class="alt"><code>			&lt;div class=&quot;alignleft&quot;&gt;&lt;?php next_posts_link(&#039;&laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;</code></li><li><code>			&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link(&#039;Next Entries &raquo;&#039;) ?&gt;&lt;/div&gt;</code></li><li class="alt"><code>		&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;?php else : ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;</code></li><li><code>		&lt;p class=&quot;center&quot;&gt;Sorry, but you are looking for something that isn&#039;t here.&lt;/p&gt;</code></li><li class="alt"><code>		&lt;?php include (TEMPLATEPATH . &quot;/searchform.php&quot;); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;?php endif; ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>&lt;?php get_sidebar(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>&lt;?php get_footer(); ?&gt;</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>&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 &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 &raquo;&#039;, &#039;1 Comment &raquo;&#039;, &#039;% Comments &raquo;&#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;&laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;
			&lt;div class=&quot;alignright&quot;&gt;&lt;?php previous_posts_link(&#039;Next Entries &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;</textarea></li></ol>
<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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php get_header(); ?&gt;</code></li><li><code>	&lt;div id=&quot;wrap&quot;&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;div id=&quot;content&quot;&gt;</code></li><li class="alt"><code>	</code></li><li><code>			&lt;?php if (have_posts()) : ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>				&lt;?php</code></li><li class="alt"><code>					if(is_home()){</code></li><li><code>	</code></li><li class="alt"><code>						include (TEMPLATEPATH . &#039;/index-loop.php&#039;);</code></li><li><code>	</code></li><li class="alt"><code>					}elseif(is_page() || is_single()){</code></li><li><code>	</code></li><li class="alt"><code>						include (TEMPLATEPATH . &#039;/single-loop.php&#039;);</code></li><li><code>	</code></li><li class="alt"><code>					}else{</code></li><li><code>	</code></li><li class="alt"><code>						include (TEMPLATEPATH . &#039;/archive-loop.php&#039;);</code></li><li><code>	</code></li><li class="alt"><code>					}</code></li><li><code>				?&gt;</code></li><li class="alt"><code>	</code></li><li><code>			&lt;?php else :?&gt;</code></li><li class="alt"><code>				&lt;h2 class=&quot;center&quot;&gt;Not Found&lt;/h2&gt;</code></li><li><code>				&lt;?php include (TEMPLATEPATH . &#039;/not-found.php&#039;);?&gt;</code></li><li class="alt"><code>			&lt;?php endif; ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;?php get_sidebar(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>&lt;?php get_footer(); ?&gt;</code></li><li><code>	</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>&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;
</textarea></li></ol>
<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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php while (have_posts()) : the_post(); ?&gt;</code></li><li><code>		&lt;h2 id=&quot;post-&lt;?php the_ID(); ?&gt;&quot; class=&quot;b&quot;&gt;</code></li><li class="alt"><code>			&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;</code></li><li><code>		&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;div class=&quot;main main_border&quot;&gt;</code></li><li class="alt"><code>	</code></li><li><code>			&lt;small&gt;</code></li><li class="alt"><code>				Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l 	\h\e jS \o\f F, Y \a	 g:i a &#039;) ?&gt; in &lt;?php the_category(&#039;, &#039;) ?&gt; &lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;</code></li><li><code>			&lt;/small&gt;</code></li><li class="alt"><code>	</code></li><li><code>				&lt;?php the_content(&#039;Continue reading &quot;&#039;.the_title(&#039;&#039;, &#039;&#039;, false).&#039;&quot;&#039;)?&gt;</code></li><li class="alt"><code>	</code></li><li><code>			&lt;div class=&quot;small box&quot;&gt;</code></li><li class="alt"><code>				//Some comment and UTW stuff				</code></li><li><code>			&lt;/div&gt;	</code></li><li class="alt"><code>		&lt;/div&gt;</code></li><li><code>&lt;?php endwhile; ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;</code></li><li class="alt"><code>	&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;&laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;</code></li><li><code>	&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 &raquo;&#039;,&#039;&#039;) ?&gt;&lt;/div&gt;</code></li><li class="alt"><code>&lt;/div&gt;</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>&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 	\h\e jS \o\f F, Y \a	 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;&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 &raquo;&#039;,&#039;&#039;) ?&gt;&lt;/div&gt;
&lt;/div&gt;</textarea></li></ol>
<p>single-loop.php (handles both singles and pages because there is only a tiny difference between the two)</p>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php while (have_posts()) : the_post(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;h2&gt;&lt;?php the_title();?&gt;&lt;/h2&gt;</code></li><li><code>	</code></li><li class="alt"><code>	</code></li><li><code>	&lt;small&gt;</code></li><li class="alt"><code>		&lt;?php if(!is_page()){ /*Only difference between pages and singles*/?&gt;</code></li><li><code>	</code></li><li class="alt"><code>			Posted on &lt;?php /*backslashes escape chars*/ the_time(&#039;l 	\h\e jS \o\f F, Y \a	 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;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;?php }else{?&gt;</code></li><li><code>	</code></li><li class="alt"><code>			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;?php } ?&gt;</code></li><li><code>	&lt;/small&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;div class=&quot;main&quot;&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;?php the_content(&#039;Read the rest of this entry &raquo;&#039;); ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;?php wp_link_pages(); ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;div class=&quot;small box&quot;&gt;</code></li><li class="alt"><code>	</code></li><li><code>			//some comment and UTW stuff</code></li><li class="alt"><code>	</code></li><li><code>		&lt;/div&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;?php posts_nav_link(&#039; &amp;#8212; &#039;, __(&#039;&laquo; Previous Page&#039;), __(&#039;Next Page &raquo;&#039;)); ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;/div&gt;</code></li><li class="alt"><code>	</code></li><li><code>&lt;?php endwhile; ?&gt;</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>&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 	\h\e jS \o\f F, Y \a	 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 &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;&laquo; Previous Page&#039;), __(&#039;Next Page &raquo;&#039;)); ?&gt;

	&lt;/div&gt;

&lt;?php endwhile; ?&gt;</textarea></li></ol>
<p>And the archive-loop.php which handles categories, date archives, tags, searches etc.</p>
<ol class='code_child' style='overflow:none' ><li class="alt"><code></code></li><li><code>		 &lt;?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is a category archive */ if (is_category()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt; Reading about &lt;?php single_cat_title(); ?&gt;&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code> 	&lt;?php /* If this is a daily archive */ } elseif (is_day()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F jS, Y&#039;); ?&gt;&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is a monthly archive */ } elseif (is_month()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;Archive for &lt;?php the_time(&#039;F, Y&#039;); ?&gt;&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is a yearly archive */ } elseif (is_year()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;Archive for &lt;?php the_time(&#039;Y&#039;); ?&gt;&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is a search */ } elseif (is_search()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;The Search Results For &quot;&lt;?php echo $s;?&gt;&quot;&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is an author archive */ } elseif (is_author()) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;Author Archive&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php /* If this is a paged archive */ } elseif (isset($_GET[&#039;paged&#039;]) &amp;&amp; !empty($_GET[&#039;paged&#039;])) { ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>		&lt;h2&gt;Archives&lt;/h2&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;?php } ?&gt;</code></li><li class="alt"><code>	</code></li><li><code>	</code></li><li class="alt"><code>	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;</code></li><li><code>		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;</code></li><li class="alt"><code>		&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 &raquo;&#039;) ?&gt;&lt;/div&gt;</code></li><li><code>	&lt;/div&gt;</code></li><li class="alt"><code>	</code></li><li><code>	</code></li><li class="alt"><code>	&lt;?php while (have_posts()) : the_post(); ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&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;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;div class=&quot;main main_border &lt;?php echo anth::styles();?&gt;&quot;&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;small&gt;</code></li><li><code>			&lt;!-- Posted &lt;?php the_time(&#039;j F Y&#039;) ?&gt;  by &lt;?php the_author() ?&gt; --&gt;</code></li><li class="alt"><code>			&lt;?php if(function_exists(&#039;UTW_ShowTagsForCurrentPost&#039;)){?&gt;</code></li><li><code>				&lt;span class=&quot;utwtags&quot;&gt;Keywords: &lt;?php UTW_ShowTagsForCurrentPost(&quot;commalist&quot;) ?&gt;&lt;/span&gt;</code></li><li class="alt"><code>			&lt;?php } ?&gt;</code></li><li><code>			&lt;?php edit_post_link(&#039;Edit&#039;,&#039;-&#039;);?&gt;</code></li><li class="alt"><code>		&lt;/small&gt;</code></li><li><code>	</code></li><li class="alt"><code>			&lt;?php the_excerpt() ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>&lt;?php endwhile; ?&gt;</code></li><li><code>	</code></li><li class="alt"><code>&lt;br/&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;div class=&quot;main&quot; style=&quot;width:99%;&quot;&gt;</code></li><li><code>		&lt;div class=&quot;main-nav-left&quot; style=&quot;float:left;width:40%;&quot;&gt;&lt;?php previous_posts_link(&#039;&laquo; Previous Entries&#039;) ?&gt;&lt;/div&gt;</code></li><li class="alt"><code>		&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 &raquo;&#039;) ?&gt;&lt;/div&gt;</code></li><li><code>	&lt;/div&gt;</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>
		 &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;&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 &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;&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 &raquo;&#039;) ?&gt;&lt;/div&gt;
	&lt;/div&gt;</textarea></li></ol>
<p>The actual loops in each of these files starts with <span class='code_child' style='display:; padding:4px;'>&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>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>&lt;?php $in_cat = cat_loop();?&gt;</code></li><li><code>	&lt;?php if($in_cat){?&gt;</code></li><li class="alt"><code>		&lt;?php include(&#039;cat_&#039;.$in_cat.&#039;.php&#039;);?&gt;</code></li><li><code>	&lt;?php } ?&gt;</code></li></ol>
<p>Which calls the function: (added to the functions.php file)</p>
<ol class='code_child' style='overflow:none' ><li class="alt"><code>	function cat_loop(){</code></li><li><code>	global $blog_id,$post, $wp_version;</code></li><li class="alt"><code>		if($wp_version &gt;= 2.3){</code></li><li><code>			global $object_term_cache;</code></li><li class="alt"><code>			$array = $object_term_cache[$blog_id][$post-&gt;ID][&#039;category&#039;];</code></li><li><code>		}else{</code></li><li class="alt"><code>			global $category_cache;</code></li><li><code>			$array = $category_cache[$blog_id][$post-&gt;ID];</code></li><li class="alt"><code>		}</code></li><li><code>		while (list($cat) = each($array)) {</code></li><li class="alt"><code>			if(file_exists(dirname(__FILE__).&#039;/cat_&#039;.$cat.&#039;.php&#039;)){</code></li><li><code>				return $cat;</code></li><li class="alt"><code>			}</code></li><li><code>		}</code></li><li class="alt"><code>	}</code></li><li>Use the following to copy and paste the code.<br /><textarea style='width:90%' cols='20' rows='5'>	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;
			}
		}
	}</textarea></li></ol>
<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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Designing flexible WordPress themes.&#039; to Del.icio.us" alt="Add &#039;Designing flexible WordPress themes.&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Designing flexible WordPress themes.&#039; to digg" alt="Add &#039;Designing flexible WordPress themes.&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Designing+flexible+WordPress+themes.&amp;u=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html" title="Add &#039;Designing flexible WordPress themes.&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Designing flexible WordPress themes.&#039; to FURL" alt="Add &#039;Designing flexible WordPress themes.&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Designing flexible WordPress themes.&#039; to reddit" alt="Add &#039;Designing flexible WordPress themes.&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html" title="Add &#039;Designing flexible WordPress themes.&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Designing flexible WordPress themes.&#039; to Technorati" alt="Add &#039;Designing flexible WordPress themes.&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Designing flexible WordPress themes.&#039; to Stumble Upon" alt="Add &#039;Designing flexible WordPress themes.&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Designing flexible WordPress themes.&#039; to Google Bookmarks" alt="Add &#039;Designing flexible WordPress themes.&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/designing-flexible-wordpress-themes.html&amp;title=Designing+flexible+WordPress+themes." title="Add &#039;Designing flexible WordPress themes.&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Designing flexible WordPress themes.&#039; to Co.mments" alt="Add &#039;Designing flexible WordPress themes.&#039; to Co.mments" />
</a>
</div>
]]></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?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=generating-semantic-comment-lists-with-xhtml</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[Dev]]></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 lists are meant to be used for content that can reasonably be displayed in any [...]]]></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.</p>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;dl&gt;</code></li><li><code>	&lt;dt&gt;John posted the following on 12/9/2007&lt;/dt&gt;</code></li><li class="alt"><code>	&lt;dd&gt;&lt;p&gt;Wow, what a great list example.&lt;/p&gt;&lt;/dd&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;dt&gt;Aaron posted the following on 13/9/2007&lt;/dt&gt;</code></li><li><code>	&lt;dd&gt;&lt;p&gt;Why thank you.&lt;/p&gt;&lt;/dd&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;dt&gt;John posted the following on 12/9/2007&lt;/dt&gt;</code></li><li class="alt"><code>	&lt;dd&gt;&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;&lt;/dd&gt;</code></li><li><code>&lt;/dl&gt;</code></li></ol>
<p>Wow, that is almost perfect. The commenter&#8217;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&#8217;t have the comment on top and the author&#8217;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>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;dl&gt;</code></li><li><code>	&lt;dd&gt;&lt;p&gt;Wow, what a great list example.&lt;/p&gt;&lt;/dd&gt;</code></li><li class="alt"><code>	&lt;dt&gt;John posted the above on 12/9/2007&lt;/dt&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;dd&gt;&lt;p&gt;Why thank you.&lt;/p&gt;&lt;/dd&gt;</code></li><li><code>	&lt;dt&gt;Aaron posted the above on 13/9/2007&lt;/dt&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;dd&gt;&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;&lt;/dd&gt;</code></li><li class="alt"><code>	&lt;dt&gt;John posted the above on 12/9/2007&lt;/dt&gt;</code></li><li><code>&lt;/dl&gt;</code></li></ol>
<p>2) You can&#8217;t logically nest &lt;dt>/&lt;dd> combinations inside each other, so you can&#8217;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&#8217;t possible to use &lt;dl>&#8217;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 &#8220;flat&#8221; (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>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;ol&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;div&gt;John posted the following on 12/9/2007&lt;/div&gt;</code></li><li class="alt"><code>		&lt;div&gt;&lt;p&gt;Wow, what a great list example.&lt;/p&gt;&lt;/div&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;li&gt;</code></li><li class="alt"><code>		&lt;div&gt;Aaron posted the following on 13/9/2007&lt;/div&gt;</code></li><li><code>		&lt;div&gt;&lt;p&gt;Why thank you.&lt;/p&gt;&lt;/div&gt;</code></li><li class="alt"><code>	&lt;/li&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;div&gt;John posted the following on 12/9/2007&lt;/div&gt;</code></li><li class="alt"><code>		&lt;div&gt;&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;&lt;/div&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>&lt;/ol&gt;</code></li></ol>
<p>The greatest strength of using the ordered list is it nests flawlessly: </p>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;ol&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;div&gt;John posted the following on 12/9/2007&lt;/div&gt;</code></li><li class="alt"><code>		&lt;div&gt;&lt;p&gt;Wow, what a great list example.&lt;/p&gt;&lt;/div&gt;</code></li><li><code>	</code></li><li class="alt"><code>		&lt;ol&gt;</code></li><li><code>			&lt;li&gt;</code></li><li class="alt"><code>				&lt;div&gt;Aaron posted the following on 13/9/2007&lt;/div&gt;</code></li><li><code>				&lt;div&gt;&lt;p&gt;Why thank you.&lt;/p&gt;&lt;/div&gt;</code></li><li class="alt"><code>	</code></li><li><code>				&lt;ol&gt;</code></li><li class="alt"><code>					&lt;li&gt;</code></li><li><code>						&lt;div&gt;John posted the following on 12/9/2007&lt;/div</code></li><li class="alt"><code>						&lt;div&gt;&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;&lt;/div&gt;</code></li><li><code>					&lt;/li&gt;</code></li><li class="alt"><code>				&lt;/ol&gt;</code></li><li><code>			&lt;/li&gt;</code></li><li class="alt"><code>		&lt;/ol&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>&lt;/ol&gt;</code></li></ol>
<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>&#8217;s don&#8217;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>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;ol&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;cite&gt;John posted the following on 12/9/2007&lt;/cite&gt;</code></li><li class="alt"><code>		&lt;blockquote&gt;&lt;p&gt;Wow, what a great list example.&lt;/p&gt;&lt;/blockquote&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;li&gt;</code></li><li class="alt"><code>		&lt;cite&gt;Aaron posted the following on 13/9/2007&lt;/cite&gt;</code></li><li><code>		&lt;blockquote&gt;&lt;p&gt;Why thank you.&lt;/p&gt;&lt;/blockquote&gt;</code></li><li class="alt"><code>	&lt;/li&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;cite&gt;John posted the following on 12/9/2007&lt;/cite&gt;</code></li><li class="alt"><code>		&lt;blockquote&gt;&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;&lt;/blockquote&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>&lt;/ol&gt;</code></li></ol>
<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&#8217;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&#8217;t think it isn&#8217;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>
<ol class='code_child' style='overflow:none'  title="Comment List example"><li class="alt"><code>&lt;ol&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;p&gt;&lt;cite&gt;John&lt;/cite&gt; posted the following on 12/9/2007&lt;/p&gt;</code></li><li class="alt"><code>		&lt;p&gt;Wow, what a great list example.&lt;/p&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>	&lt;li&gt;</code></li><li class="alt"><code>		&lt;p&gt;&lt;cite&gt;Aaron&lt;/cite&gt; posted the following on 13/9/2007&lt;/p&gt;</code></li><li><code>		&lt;p&gt;Why thank you.&lt;/p&gt;</code></li><li class="alt"><code>	&lt;/li&gt;</code></li><li><code>	</code></li><li class="alt"><code>	&lt;li&gt;</code></li><li><code>		&lt;p&gt;&lt;cite&gt;John&lt;/cite&gt; posted the following on 13/9/2007&lt;/p&gt;</code></li><li class="alt"><code>		&lt;p&gt;You are very welcome. The list is flawless.&lt;/p&gt;</code></li><li><code>	&lt;/li&gt;</code></li><li class="alt"><code>	</code></li><li><code>&lt;/ol&gt;</code></li></ol>
<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&#8217;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>&#8217;s and &lt;span>&#8217;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>
<div class="social_bookmark">
<em>Bookmark</em><br />
<a class="social_img" rel="nofollow" href="http://del.icio.us/post?url=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Del.icio.us" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Del.icio.us" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Del.icio.us" />
</a>
<a class="social_img" rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to digg" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to digg" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to digg" />
</a>
<a class="social_img" rel="nofollow" href="http://furl.net/storeIt.jsp?t=Generating+Semantic+Comment+Lists+with+XHTML&amp;u=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to FURL" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to FURL" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to FURL" />
</a>
<a class="social_img" rel="nofollow" href="http://reddit.com/submit?url=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to reddit" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to reddit" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to reddit" />
</a>
<a class="social_img" rel="nofollow" href="http://www.technorati.com/faves?add=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Technorati" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Technorati" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Technorati" />
</a>
<a class="social_img" rel="nofollow" href="http://www.stumbleupon.com/submit?url=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Stumble Upon" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Stumble Upon" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Stumble Upon" />
</a>
<a class="social_img" rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Google Bookmarks" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Google Bookmarks" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Google Bookmarks" />
</a>
<a class="social_img" rel="nofollow" href="http://co.mments.com/track?url=http://anthologyoi.com/dev/generating-semantic-comment-lists-with-xhtml.html&amp;title=Generating+Semantic+Comment+Lists+with+XHTML" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Co.mments" ><img src="http://anthologyoi.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Co.mments" alt="Add &#039;Generating Semantic Comment Lists with XHTML&#039; to Co.mments" />
</a>
</div>
]]></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>

