<?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>mummey.org</title>
	<atom:link href="http://www.mummey.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mummey.org</link>
	<description>Personal Website of Adrian Mummey</description>
	<lastBuildDate>Tue, 27 Oct 2009 03:11:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Make an Awesome functions.php File For You New Wordpress Template &#8211; Part 1</title>
		<link>http://www.mummey.org/2009/10/make-an-awesome-functions-php-file-for-you-new-wordpress-template-part-1/</link>
		<comments>http://www.mummey.org/2009/10/make-an-awesome-functions-php-file-for-you-new-wordpress-template-part-1/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 01:25:59 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=541</guid>
		<description><![CDATA[Its been awhile since I threw up a new blog post. Been working hard and trying to finish up some grad-school applications. However I have been in the midst of creating a new Wordpress theme and have discovered that a really great functions.php file can be an enormous help for the template designer AND for [...]]]></description>
			<content:encoded><![CDATA[<p>Its been awhile since I threw up a new blog post. Been working hard and trying to finish up some grad-school applications. However I have been in the midst of creating a new Wordpress theme and have discovered that a really great functions.php file can be an enormous help for the template designer AND for whoever may need to edit your template later. If you are considering creating a template that you will eventually distribute or if you know that someone besides you will eventually have to modify the template you should definitely put a lot of thought into your functions.php file. In this post I am going to put some generic and useful functions and shortcode included that you can use if you like. Note: It is good practice to put a prefix before your functions. You don&#8217;t want use the same function names as Wordpress or other plugins, because this will cause an error. You can create a pseudo-namespace for you functions by prepending them with some generic prefix. Here I am using AM.</p>
<h3>Easily Grab a Custom Field</h3>
<p>Wordpress is not a CMS, however many developers are using the built in functionality of Wordpress to mimic some of the features of a CMS. One of the most helpful features are Custom Fields. These will allow you to associate unique data with each page or post. This function is a nice wrapper for the built in one for grabbing a custom field:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> AM_get_custom_field_value<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$echo</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>  
  <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$echo</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Note: this function will only grab a single value for your custom field. In order to grab the whole array, here is a different function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> AM_get_custom_field_values<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>  
  <span style="color: #000088;">$post_id</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Insert a Single, Specific Post Into Your Template</h3>
<p>Often times clients want to be able to edit certain parts of a webpage without editing the template code. With most modern CMSes this is handled using modules or something similar. Although Wordpress has Widgets, one big downside of using them is that the text widget doesn&#8217;t have the same nice WYSIWYG that a post or page does. One way around this is to create specific posts that contain editable blocks of text and display them directly in your template. Now, this isn&#8217;t exactly the &#8220;proper&#8221; use of posts, but who cares, it gets the job done. One thing to remember though, if you don&#8217;t want this text showing up in your blog lists, you must make sure NOT to publish it. The other thing is that you will need to get the Post ID for the post you want to display. This is available in the URL while editing the post:</p>
<pre>wp-admin/post.php?action=edit&#038;<strong>post=541</strong>&#038;message=1</pre>
<p>In this case the Post ID is 541.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> AM_get_single_post<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$echo</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
  query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p='</span><span style="color: #339933;">.</span><span style="color: #000088;">$postID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> 
  <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">//Reset Query</span>
  wp_reset_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$post_content</span><span style="color: #339933;">=</span> <span style="color: #990000;">ob_get_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$echo</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$post_content</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$post_content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Insert a Post Inside a Post</h3>
<p>This might seem like a useless function, but I have actually used it quite successfully. It goes along the same lines as the above function but will allow you to insert a post inside another post using shortcode. I recently used this for a client who wanted an editable block of text, but wanted to put it on only certain posts. It didn&#8217;t seem to necessitate a whole different template file for this, so I decided to write this function. In order to use it, you need to add this shortcode inside your post:</p>
<pre>[insert_the_post id="88"]</pre>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> insert_the_post_func<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p='</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//The Loop</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> 
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Reset Query</span>
    wp_reset_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'insert_the_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'insert_the_post_func'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F10%2Fmake-an-awesome-functions-php-file-for-you-new-wordpress-template-part-1%2F&amp;linkname=Make%20an%20Awesome%20functions.php%20File%20For%20You%20New%20Wordpress%20Template%20%26%238211%3B%20Part%201"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/10/make-an-awesome-functions-php-file-for-you-new-wordpress-template-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YAML &#8211; My Favorite Non-Markup Language</title>
		<link>http://www.mummey.org/2009/04/yaml-my-favorite-non-markup-language/</link>
		<comments>http://www.mummey.org/2009/04/yaml-my-favorite-non-markup-language/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 12:02:53 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=527</guid>
		<description><![CDATA[I have been using YAML for awhile and decided I’d like to write a post about it. YAML is an acronym for YAML Ain’t Markup Language and it is a very useful and concise serialization standard. I use YAML all the time in when I am coding PHP projects that require some kind of configuration files. ]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://www.yaml.org/" title="YAML" alt="YAML" target="_blank">YAML</a> for awhile and decided I&#8217;d like to write a post about it. YAML is an acronym for YAML Ain&#8217;t Markup Language and it is a very useful and concise serialization standard. I use YAML all the time in when I am coding PHP projects that require some kind of configuration files.
<div style="clear:both;"></div>
<p>Here is what <a href="http://en.wikipedia.org/wiki/YAML" title="wiki" alt="wiki" target="_blank">wiki</a> says about it:</p>
<blockquote><p>YAML syntax was designed to be easily mapped to data types common to most high-level languages: list, hash, and scalar. Its familiar indented outline and lean appearance makes it especially suited for tasks where humans are likely to view or edit data structures, such as configuration files, dumping during debugging, and document headers (e.g. the headers found on most e-mails are very close to YAML). Although well-suited for hierarchical data representation, it also has a compact syntax for a relational data as well.</p></blockquote>
<p>Here is a sample of what YAML looks like:</p>
<pre><code class="php">connection: "local_mysql"
widget:
  type: "Table"
drawProperties:
  title: "Syslog Table"
  showRowNumber: "true"
  allowHtml: "true"
  pageSize: null
  page: "disable"
#usually the table name
entityName: logs
entity:
  table: logs
  fields:
    id:
      field: id
      type: number
    counter:
      field: counter
      type: number
initialQuery: "select id, counter from logs order by id"</code></pre>
<p>One of the great things about YAML is that it is very easy to read and takes much less syntax markup than XML. This enables you to crank out tight, clean configuration files very easily. When I load the previous YAML file up into PHP, here is the resulting data structure:</p>
<pre><code class="php">array(6) {
  [&quot;connection&quot;]=&gt;
  string(11) &quot;local_mysql&quot;
  [&quot;widget&quot;]=&gt;
  array(1) {
    [&quot;type&quot;]=&gt;
    string(5) &quot;Table&quot;
  }
  [&quot;drawProperties&quot;]=&gt;
  array(4) {
    [&quot;title&quot;]=&gt;
    string(12) &quot;Syslog Table&quot;
    [&quot;showRowNumber&quot;]=&gt;
    string(4) &quot;true&quot;
    [&quot;allowHtml&quot;]=&gt;
    string(4) &quot;true&quot;
    [&quot;page&quot;]=&gt;
    string(7) &quot;disable&quot;
  }
  [&quot;entityName&quot;]=&gt;
  string(4) &quot;logs&quot;
  [&quot;entity&quot;]=&gt;
  array(2) {
    [&quot;table&quot;]=&gt;
    string(4) &quot;logs&quot;
    [&quot;fields&quot;]=&gt;
    array(2) {
      [&quot;id&quot;]=&gt;
      array(2) {
        [&quot;field&quot;]=&gt;
        string(2) &quot;id&quot;
        [&quot;type&quot;]=&gt;
        string(6) &quot;number&quot;
      }
      [&quot;counter&quot;]=&gt;
      array(2) {
        [&quot;field&quot;]=&gt;
        string(7) &quot;counter&quot;
        [&quot;type&quot;]=&gt;
        string(6) &quot;number&quot;
      }
    }
  }
  [&quot;initialQuery&quot;]=&gt;
  string(40) &quot;select id, counter from logs order by id&quot;
}</code></pre>
<p>The YAML file is actually parsed using a PHP YAML parser called <a href="http://spyc.sourceforge.net" title="Spyc" alt="Spyc" target="_blank">Spyc</a>. The syntax for Spyc is also quite simple:</p>
<pre><code class="php">$configArray = Spyc::YAMLLoad($yamlFile);</code></pre>
<p>I was first introduced to YAML files when I began a Symfony project. Symfony makes heavy use of YAML files for all of its configuration. I really like the way Symfony was so configurable and have since added YAML config files to just about every project I work on. They are far easier to edit than XML, there is less overhead when parsing and apparently the YAML 1.2 specification is compatible with JSON which is amazing.<br />
From <a href="http://en.wikipedia.org/wiki/JSON" title="wikipedia YAML JSON" alt="wikipedia" target="_blank">wikipedia</a>:</p>
<blockquote><p>Both functionally and syntactically, JSON is effectively a subset of YAML. Specifically, as of YAML version 1.2, &#8220;every JSON file is also a valid YAML file&#8221;</p></blockquote>
<p>Configuration files are a great way to make your life easier, and the life of anyone else who need to modify your code and YAML is a great place to start for creating these.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F04%2Fyaml-my-favorite-non-markup-language%2F&amp;linkname=YAML%20%26%238211%3B%20My%20Favorite%20Non-Markup%20Language"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/04/yaml-my-favorite-non-markup-language/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Finding a Category Ancestor / Descendant for WP Templates</title>
		<link>http://www.mummey.org/2009/03/finding-a-category-ancestor-descendant-wp-templates/</link>
		<comments>http://www.mummey.org/2009/03/finding-a-category-ancestor-descendant-wp-templates/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 06:01:02 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[ancestor]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[children]]></category>
		<category><![CDATA[descendent]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=365</guid>
		<description><![CDATA[Recently I had a problem where I needed to find out if a specific category was a descendant of another category, or if one category was a ancestor of another. The latest website I am working on has a top level category called &#8220;Trips we do&#8221; and below that are many sub-categories and sub-sub categories [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a problem where I needed to find out if a specific category was a descendant of another category, or if one category was a ancestor of another. The latest website I am working on has a top level category called &#8220;Trips we do&#8221; and below that are many sub-categories and sub-sub categories etc. I wanted to use the same template on all of the categories that were descended from the &#8220;Trips we do&#8221;.<br />
Wordpress already has a function that returns the parent categories <a href="http://codex.wordpress.org/Template_Tags/get_category_parents">get_category_parents</a> but this returns a string more suited for breadcrumbs. I needed a yes or no answer that my category in question was in fact descended from some other arbitrary category. Here is the function I produced:</p>
<pre><code class="php">function is_ancestor_cat($ancestor, $descendant){
  $ancestor = (string) $ancestor;
  $desc_id = (string) $descendant;
  $child_cats = get_term_children( (string) $ancestor, &#39;category&#39;);
  if($ancestor == $descendant){
    return true;
  }
  else if(!count($child_cats)){
    return false;
  }
  else{
    $is_child = false;
    foreach($child_cats as $cat_id){
      if($cat_id == $desc_id){
        $is_child = true;
        break;
      }
      else{
        $is_child = $is_child || is_ancestor_cat($cat_id, $descendant);
      }
    }
    return $is_child;
  }
}</code></pre>
<p>What this code does is that is grabs all the children for the <em>ancestor</em> category then checks them against the <em>descendant</em> category, it will keep recursing until it hits the leaf nodes and returns a boolean value.<br />
Here it is in action in my template file <em>category.php</em>:</p>
<pre><code class="php">//Check if we are in a category
if(is_category()){
  $ancestor_cat_id = 43;
  //Lets get the current category we are in
  $cur_cat_id = get_cat_id( single_cat_title(&quot;&quot;,false) );
  $is_ancestor = false;
  //Check if we are in the ancestor category
  $is_ancestor = is_ancestor_cat($ancestor_cat_id, $cur_cat_id);

  //If it is an ancestor, use a specific template
  if($is_ancestor){
   include(TEMPLATEPATH.&#39;/category-43.php&#39;);
  }
  //Use the default template
  else{
   include(TEMPLATEPATH.&#39;/category-default.php&#39;);
  }

}</code></pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F03%2Ffinding-a-category-ancestor-descendant-wp-templates%2F&amp;linkname=Finding%20a%20Category%20Ancestor%20%2F%20Descendant%20for%20WP%20Templates"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/03/finding-a-category-ancestor-descendant-wp-templates/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Agony and Ecstasy &#8211; Creating a Wordpress Plugin</title>
		<link>http://www.mummey.org/2009/03/the-agony-and-ecstasy-creating-a-wordpress-plugin/</link>
		<comments>http://www.mummey.org/2009/03/the-agony-and-ecstasy-creating-a-wordpress-plugin/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 14:21:46 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=332</guid>
		<description><![CDATA[The time has come for me to finally publish a post about my recent foray into Wordpress plugin development. I am by no means an expert on the subject and maybe that is why this guide can be helpful for the newbie. Prior to this I have done extensive plugin and development work on Joomla! [...]]]></description>
			<content:encoded><![CDATA[<p>The time has come for me to finally publish a post about my recent foray into Wordpress plugin development. I am by no means an expert on the subject and maybe that is why this guide can be helpful for the newbie. Prior to this I have done extensive plugin and development work on Joomla! so I figured it shouldn&#8217;t be to hard to do something for Wordpress. I have been working with WP websites for only about a year or so and have grown to love the platform. I had written my cSprites core API and was looking for a platform to implement a plugin for and decided it would be a good chance to learn all about Wordpress.</p>
<p>It has been about two weeks from when I first decided to write my plugin, to today. Luckily for the time being I don&#8217;t have much other work so I have been able to dedicate quite a bit of my time to development of this plugin. I am really happy how far its come in the past two weeks, with about 800 downloads so far and a fairly stable version now.</p>
<p>There really isn&#8217;t too much organization to this post, really just a hodgepodge of various tools, tips, ideas and links that have been helpful to me. This isn&#8217;t meant to be a comprehensive &#8220;My first WP plugin tutorial&#8221;, there are already plenty of those. This is meant to be what comes after that, when you are scratching your head trying to figure something out (which I did plenty of!) or when you want to make sure you haven&#8217;t forgot. Also I don&#8217;t want to claim to be any kind of expert on the subject, considering this is my one and only plugin.</p>
<p>One lesson I have learned though, is learn from the best. I spent a lot of time looking through the source code of really popular and well establish plugins like NextGen Gallery. Studying this code can provide a lot of insight into how problems are solved, security, internationalization and other things you need to know in order to write a good plugin.</p>
<p>Anyways without further ado, here is a list of some stuff to think about:</p>
<ol>
<li><a href="#svn" title="svn" alt="svn">SVN</a></li>
<li><a href="#readme" title="readme" alt="readme">The Readme &amp; Main File Headers</a></li>
<li><a href="#helpful_constants" title="helpful constants" alt="helpful_constants">Helpful Constants</a></li>
<li><a href="#preflight_checks" title="preflight_checks" alt="preflight_checks">Preflight Checks</a></li>
<li><a href="#hooks_actions" title="hooks_actions" alt="hooks_actions">Hooks &amp; Actions</a></li>
<li><a href="#uninstall" title="uninstall" alt="uninstall">Uninstall</a></li>
<li><a href="#admin_options" title="admin_options" alt="admin_options">Admin Options</a></li>
<li><a href="#tread_lightly" title="tread_lightly" alt="tread_lightly">Tread Lightly</a></li>
</ol>
<hr/>
<a name="svn"></a><br />
<h3>SVN</h3>
<p><a href="http://wordpress.org/extend/plugins/about/svn/" title="SVN tutorial" target="_blank">Wordpress SVN Tutorial</a></p>
<p>The Wordpress SVN integration is a definite must to know when starting your projects.  I use Coda for development, which has integrated SVN but I am not sure its ready for primetime as I still have some problems using it. So I ended up using <a title="SCplugin" href="http://scplugin.tigris.org/" target="_blank">SCplugin</a> which integrates nicely into the finder and works like a charm. Once I can afford it, I am going to buy <a title="Versions for Mac" href="http://versionsapp.com/" target="_blank">Versions</a> which looks even better and has much more functionality. I also tend to use the command line when performing certain functions.</p>
<p>To start my project (after signing up with Wordpress and getting my account information) all I did was use SCplugin to checkout the base folder structure from the Wordpress repository and started working on it. It was really easy. Also the base folder strucutre includes trunk, branches and tags so should have most everything you need. Here are some of the commands I use:</p>
<pre><code class="html">svn co http://svn.wp-plugins.org/csprites-for-wordpress/ myfolder</code></pre>
<p>Use this to check out the entire tree.</p>
<pre><code class="html">svn co http://svn.wp-plugins.org/csprites-for-wordpress/trunk myworkingdir</code></pre>
<p>I use this to just check out the trunk when I am doing development, so I can test it directly in my WP install</p>
<pre><code class="html">svn cp trunk tags/0.495</code></pre>
<p>This will create a new tagged version, which is important when using WP&#8217;s plugin repository and packaging service. The version in your readme and base plugin file need to match one of these tags.</p>
<pre><code class="html">svn merge -r 91101:HEAD  branches/benchmark/ trunk</code></pre>
<p>I created a branch for benchmarking purposes and did some work on it. Eventually I used the above code to merge my changes from the benchmark branch back into the trunk</p>
<pre><code class="html">svn log</code></pre>
<p>You can call this in one of your repository directories to get a log of all the changes. This can be useful when you need to find a revision when doing a merge.<br />
<a name="readme"></a><br />
<h3>The Readme &amp; Main File Headers</h3>
<p><a href="http://wordpress.org/extend/plugins/about/readme.txt" title="Wordpress Readme Standard" target="_blank">Wordpress Readme Standard</a> | <a href="http://wordpress.org/extend/plugins/about/validator/" title="Wordpress Readme Validator" target="_blank">Wordpress Readme Validator</a></p>
<p>The readme.txt file is arguably one of the more important file in your whole plugin. It is parsed by the WP plugins server and displays a lot of relevant information on your plugin. It is important to keep this information up to date.</p>
<pre><code class="html">=== cSprites - Speed Up Page Load Time with Dynamic Image Sprites ===
Contributors: amummey
Tags: css, sprites, cSprites, images, content
Stable tag: 0.5
Requires at least: 2.7
Tested up to: 2.7.1
Donate link: http://mummey.org/csprites/

Automatically compress you content images into a big sprite, decreasing web page load time.</code></pre>
<p>The top of my <strong>readme.txt</strong> file, this should be in your root directory. You can also add screenshots of you project by putting files in your root plugin directory and naming them <em>screenshot-1.jpg, screenshot-2.jpg&#8230;</em></p>
<pre><code class="html">/*
Plugin Name: cSprites for Wordpress
Plugin URI: http://wordpress.org/extend/plugins/csprites-for-wordpress/
Description: Automatically compress you content images into a big sprite, decreasing web page load time.
Version: 0.5
Author: Adrian Mummey
Author URI: http://mummey.org/
Copyright 2008-2009 Adrian Mummey

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
</code></pre>
<p>The header of my main <strong>wp_csprites.php</strong>. Here I have included some more formatted information about the plugin. One thing to remember is that the <strong>Version</strong> number here should match the version in your <strong>readme.txt</strong> file for the Wordpress plugin server to recognize your latest version. I have forgotten to make these the same and wondered why my plugins page wasn&#8217;t updating. I have also included the license in my header.</p>
<p>Another thing is that when you commit a new version, it may not be recognized right away, there is some delay so wait 15 minutes or so and come back and refresh the page on Wordpress before you start panicking. Also I have noticed there is quite some delay in the automatic update feature on the plugin page in WP admin. It can take a few hours sometimes before my Admin shows me there is a new version of my plugin.<br />
<a name="helpful_constants"></a><br />
<h3>Helpful Constants</h3>
<pre><code class="html">WP_PLUGIN_DIR</code></pre>
<p>This constant will give you the <strong>Absolute</strong> directory path of the plugins directory. This is helpful when you need to do some file reads or writes.</p>
<pre><code class="html">WP_PLUGIN_URL</code></pre>
<p>This constant will give you the full url path to the plugin directory.</p>
<pre><code class="php">define('CSPRITE_PLUGIN_NAME', basename(dirname(__FILE__)));
define('CSPRITE_PLUGIN_DIR', WP_PLUGIN_DIR.'/'.CSPRITE_PLUGIN_NAME);
define('CSPRITE_PLUGIN_URL', WP_PLUGIN_URL.'/'.CSPRITE_PLUGIN_NAME);</code></pre>
<p>This is a quick way to define some constants that point to your plugins directory.<br />
<a name="preflight_checks"></a><br />
<h3>Preflight Checks</h3>
<p>Before you put your plugin out, you need to be sure that all the requirements for its proper execution are met. If they aren&#8217;t you should degrade gracefully and not show any errors. In my plugin I wrote some preflight checks to make sure all the requirements are met before I hooked into wordpress. In addition, if the preconditions are not met, I will display a nice message for the user to tell them why the plugin isn&#8217;t working.</p>
<pre><code class="html">function cSpriteCheckPhpVersion(){
  return version_compare(PHP_VERSION, '5.0.0', '>');
}</code></pre>
<p>This function will make sure that PHP version is higher than 5.0.0 (a requirement of my plugin).</p>
<pre><code class="html">function cSpriteCheckWordPressVersion(){
  global $wp_version;
  $minimum_wp = '2.7';
  return version_compare($wp_version, $minimum_wp, '>=');
}</code></pre>
<p>Wordpress has a global version variable that you can use to check the current running version of Wordpress.</p>
<pre><code class="html">function cSpriteCheckCacheWritable(){
  $file = CSPRITE_CACHE_DIR.'/permission.txt';
  return (@file_put_contents($file, 'sanity check') !== false);
}</code></pre>
<p>This check tries to write a small file to my cache directory. It is essential for the proper execution of my plugin for the cache directory to be writable.<br />
<a name="hooks_actions"></a><br />
<h3>Hooks and Actions</h3>
<p>There is a lot of documentation already written about most of the hooks and action, but I thought I would just cover a few here that don&#8217;t have as much written about them, but can be useful.</p>
<pre><code class="php">add_action('plugins_loaded', 'startcSprites');</code></pre>
<p>I wrap all the plugin initialization code in a function called <em>startcSprites</em> which is handled by the <em>plugins_loaded</em> hook.</p>
<pre><code class="php">add_action('loop_start', 'cSpriteLoopStart');</code></pre>
<p>Since I need to parse all of the content before its displayed I use this action hook to call a function to parse all the posts at the beginning of the loop. </p>
<pre><code class="php">function cSpriteLoopStart(){
  global $wp_query;

  if(in_the_loop() &amp;&amp; !is_admin()){
    $the_posts = $wp_query-&gt;posts;
    foreach($the_posts as $post){
      $content = $post-&gt;post_content;
    	$content = apply_filters(&#39;the_content&#39;, $content);
    	$content = str_replace(&#39;]]&gt;&#39;, &#39;]]&amp;gt;&#39;, $content);
    	$content = do_shortcode($content);
      cSpriteFindImg($content);
    }
    if(SpritePreprocessorCache::preprocessorCacheNeedsCreation()){
        SpritePreprocessorCache::registerImageSources();
        Sprite::process();
    }
    add_filter(&#39;the_content&#39;, &#39;cSpriteImgReplace&#39;,50);
  }

}</code></pre>
<p>And then here is the code to process the posts one at a time inside the loop_start hook.<br />
<a name="uninstall"></a><br />
<h3>Uninstall</h3>
<p>When writing a plugin, you should make sure you clean up what you left behind after the plugin is removed. Luckily Wordpress gives us a handy hook when dealing with this. I have a file called <em>uninstall.php</em>:</p>
<pre><code class="php">if ( function_exists(&#39;register_uninstall_hook&#39;) )
	register_uninstall_hook(__FILE__, &#39;cSpriteUninstall&#39;);</code></pre>
<p>This registers my uninstall function, which is located in the same file. The only changes I make to Wordpress are to add some options, so I just removed all the options I previously set.</p>
<pre><code class="php">function cSpriteUninstall() {
  delete_option(&#39;cSpriteJpgQuality&#39;);
  delete_option(&#39;cSpritePngCompression&#39;);
  delete_option(&#39;cSpriteCacheTime&#39;);
  delete_option(&#39;cSpriteForceNoPadding&#39;);
  delete_option(&#39;cSpriteClearCacheNow&#39;);
  delete_option(&#39;cSpriteProcessPng&#39;);
  delete_option(&#39;cSpriteProcessJpg&#39;);
  delete_option(&#39;cSpriteProcessGif&#39;);
}</code></pre>
<p><a name="admin_options"></a><br />
<h3>Admin Options Page</h3>
<p>Wordpress has a really nice way to handle your plugin options, it provides some special hooks and takes care of all the database stuff for you which is really nice. There are a couple ways to hook into it, the route I used is to first check if the user is acutally in an admin page, I have this function, which is a modified one from <a href="http://alexking.org/blog/2005/05/25/is_admin_page-for-wordpress" title="is_admin_page function">here</a>:</p>
<pre><code class="php">if (!function_exists(&#39;is_admin_page&#39;)) {
	function is_admin_page() {
		if (function_exists(&#39;is_admin&#39;)) {
			return is_admin();
		}
		if (function_exists(&#39;check_admin_referer&#39;)) {
			return true;
		}
		else {
			return false;
		}
	}
}</code></pre>
<p>I do this check before adding the hooks. In addition I do a security check to make sure the current user has access to modify options.</p>
<pre><code class="php">if (current_user_can(&#39;manage_options&#39;)) {
        add_action(&#39;admin_menu&#39;, &#39;cSpriteAdminMenu&#39;);
        add_action(&#39;update_option_cSpriteClearCacheNow&#39;, &#39;cSpriteClearCache&#39;);
 }</code></pre>
<p>Only after these two checks will I add the hooks. The first hook is to create the options page link on the left nav bar. And the function it calls will actually provide another callback to display the options form.</p>
<pre><code class="php">function cSpriteAdminMenu() {
  add_options_page(__('cSprites Options', CSPRITE_PLUGIN_NAME), __('cSprites', CSPRITE_PLUGIN_NAME), 8, __FILE__, 'cSpriteOptionsPage');
}</code></pre>
<p>This will call a function named <em>cSpriteOptionsPage</em> that will output all the HTML needed for the function. The second hook from above <em>update_option_cSpriteClearCacheNow</em> is used because when the cSpriteClearCacheNow option is modified I need to do some specialized work that the default WP options handlers do not take care of. This is the function it calls, essentially deleting all the files in my cache:</p>
<pre><code class="php">function cSpriteClearCache(){
  remove_action(&#39;update_option_cSpriteClearCacheNow&#39;, &#39;cSpriteClearCache&#39;);
  if(isset($_REQUEST[&#39;cSpriteClearCacheNow&#39;])){
    Sprite::clearCache();
  }
  update_option(&#39;cSpriteClearCacheNow&#39;, 0);
  return 0;
}</code></pre>
<p>The function needs to return the new value of the option being modified. Since this isn&#8217;t a toggle switch I will always return zero to reset that option. You will notice that I first had to remove the action, this is because if I dont&apos;t then the following call to update_option will keep propagating and get stuck in an endless loop.</p>
<h4>Adding CSS and JS to You Admin Options Page</h4>
<p>I wanted to spruce up my options page with some custom CSS and nice jQuery UI elements. Wordpress once again provides some more hooks to do this.</p>
<pre><code class="php">//Only load scripts and styles if we are on the csprites option page
      if(strstr($_REQUEST[&#39;page&#39;], CSPRITE_PLUGIN_NAME)!== false){
        if (function_exists(&#39;wp_enqueue_style&#39;)) {
          wp_enqueue_style(&#39;cSpritesAdminStyles&#39;, trailingslashit(CSPRITE_CSS_URL_DIR).&#39;csprites.min.css&#39;, array(), &#39;&#39;, &#39;screen&#39;);
        }
        if (function_exists(&#39;wp_enqueue_script&#39;)) {
          wp_enqueue_script(&#39;cSpritesCheckbox&#39;, trailingslashit(CSPRITE_JS_URL_DIR).&#39;jquery.checkbox.js&#39;, array(&#39;jquery&#39;), &#39;1.0&#39;);
          wp_enqueue_script(&#39;jquery-slider&#39;, trailingslashit(CSPRITE_JS_URL_DIR).&#39;ui.slider.js&#39;, array(&#39;jquery&#39;, &#39;jquery-ui-core&#39;), &#39;1.0&#39;);
          wp_enqueue_script(&#39;cSpriteInit&#39;, trailingslashit(CSPRITE_JS_URL_DIR).&#39;csprites.js&#39;, array(&#39;jquery-slider&#39;), &#39;1.0&#39;);        }

        add_action(&#39;admin_head&#39;, &#39;wp_print_styles&#39;, &#39;100&#39;);
      }</code></pre>
<p>Before loading the scripts and CSS I do a check to make sure that the admin is currently on the cSprites option page. The next function call is to <em>wp_enqueue_script</em>. This will put my custom CSS file in the style queue and will be outputted when the <em>wp_print_styles function</em> is called. Next I add my scripts to the queue with <em>wp_enqueue_script</em>. The cool part of this function is that you can specify dependencies for your scripts. In my case I wanted to use the jQuery Slider, so my script dependecies are <strong>jquery</strong> and <strong>jquery-ui-core</strong>. Wordpress will automatically put the code for these scripts before your custom JS files are added. The list of bundled scripts are located here in the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="Function Reference - wp enqueue script">Wordpress Codex</a>.</p>
<p>Lastly I added an action which will call the <em>wp_print_styles</em> function when the header is called.<br />
<a name="tread_lightly"></a><br />
<h3>Tread Lightly</h3>
<p>One thing to be aware of is that most of these hooks that wordpress provides will always be called at some point, in administrator and the frontend. It may be unnecessary for you to include CSS and JS in the header if your plugin isn&#8217;t being used on the page being viewed. It is important to make sure that your plugin is only being run when you want it to. This will avoid potential conflicts and wasted bandwith. </p>
<p>In addition, when using custom javascript, don&apos;t re-include libraries like jquery and prototype, because WP already has them and it does a pretty good job of handling them. So when appropriate you should always use <em>wp_enqueue_script</em> with the proper dependencies.</p>
<p>This will be an ongoing article once I get around to adding more stuff <img src='http://www.mummey.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' title="The Agony and Ecstasy   Creating a Wordpress Plugin" /> </p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F03%2Fthe-agony-and-ecstasy-creating-a-wordpress-plugin%2F&amp;linkname=The%20Agony%20and%20Ecstasy%20%26%238211%3B%20Creating%20a%20Wordpress%20Plugin"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/03/the-agony-and-ecstasy-creating-a-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Styling Wordpress Dynamic Sidebar &#8211; dynamic_sidebar_params Filter</title>
		<link>http://www.mummey.org/2009/02/styling-wordpress-dynamic-sidebar-dynamic_sidebar_params-filter/</link>
		<comments>http://www.mummey.org/2009/02/styling-wordpress-dynamic-sidebar-dynamic_sidebar_params-filter/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 04:38:23 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dynamic sidebar]]></category>
		<category><![CDATA[dynamic_sidebar_params]]></category>
		<category><![CDATA[filter]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=166</guid>
		<description><![CDATA[I have been working a lot lately on customizing my personal homepage theme. One thing I have not been happy about has been the right sidebar. The widget heading were just html text and didn&#8217;t have the rendered look that I wanted. I decided to reformat the sidebar and use images for the headings rather [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working a lot lately on customizing my personal homepage theme. One thing I have not been happy about has been the right sidebar. The widget heading were just html text and didn&#8217;t have the rendered look that I wanted. I decided to reformat the sidebar and use images for the headings rather than just text. I had done some custom sidebars before but I wasn&#8217;t sure how to style each widget independently. The problem is that WP gives a generic class to each sidebar widget and you are only able to style all of them to look the same.<br />
The first place I looked for a function to do this was in my template&#8217;s function.php file and I noticed this code:</p>
<pre><code class="php">
if ( function_exists(&#39;register_sidebar&#39;) )
    register_sidebar(array(
        &#39;before_widget&#39; =&gt; &#39;&lt;div class=&quot;sidebar-box&quot;&gt;&#39;,
    &#39;after_widget&#39; =&gt; &#39;&lt;/div&gt;&lt;/div&gt;&#39;,
 &#39;before_title&#39; =&gt; &#39;&lt;h2&gt;&lt;span&gt;&#39;,
        &#39;after_title&#39; =&gt; &#39;&lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;sidebar-box-inside&quot;&gt;&#39;,
    ));
</code></pre>
<p>This isn&#8217;t exacly what I wanted as it will apply this to all of my widgets. So after a little more snooping around the web I noticed a WP filter that does what I want. The fitler is called <em>dynamic_sidebar_params</em> and it is called like this:</p>
<pre><code class="php">
add_filter('dynamic_sidebar_params', 'my_function_callback');
</code></pre>
<p>Where <em>my_function_callback</em> is the name of your function. In my case I called it like this, in <em>functions.php</em>:</p>
<pre><code class="php">
add_filter('dynamic_sidebar_params', 'sidebar_styling');
</code></pre>
<p>Next I had to figure out a way to style each element uniquely. I decided that the widget name would be a good identifier. Luckily this filter will pass you a field called widget_id, which has a sanitized version of the name which can be used for your CSS identifier. Here is what the params variable looks like:</p>
<pre><code class="php">
Array
(
    [name] =&gt; Sidebar 1
    [id] =&gt; sidebar-1
    [before_widget] =&gt; &lt;div class=&quot;sidebar-box&quot;&gt;

    [after_widget] =&gt; &lt;/div&gt;&lt;/div&gt;
    [before_title] =&gt; &lt;h2&gt;&lt;span&gt;
    [after_title] =&gt; &lt;/span&gt;&lt;/h2&gt;&lt;div class=&quot;sidebar-box-inside&quot;&gt;
    [widget_id] =&gt; recent-posts
    [widget_name] =&gt; Recent Posts
)
</code></pre>
<p>Now that we have that ID, it is a simple function to write:</p>
<pre><code class="php">function sidebar_styling($params){
  $params[0][&#39;before_title&#39;] = &#39;&lt;h2 id=&quot;sidebar-&#39;.@$params[0][&#39;widget_id&#39;].&#39;&quot;&gt;&lt;span&gt;&#39;;
  return $params;
}</code></pre>
<p>Now WP will output the unique id for each heading and we can just style it appropriately. I used a big sprite to save resources:<br />
<div id="attachment_169" class="wp-caption aligncenter" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/dynamic-sidebar.png"><img src="http://www.mummey.org/wp-content/uploads/2009/02/dynamic-sidebar-150x150.png" alt="Dynamic Sidebar" title="dynamic-sidebar" width="150" height="150" class="size-thumbnail wp-image-169" /></a><p class="wp-caption-text">Dynamic Sidebar</p></div><br />
And then styled it like this, I am hiding the span so that we don&#8217;t see the text, but it will degrade nicely if you haven&#8217;t yet styled one of your widget classes.</p>
<pre><code class="css">
#sidebar-recent-posts span{display: none;}
#sidebar-recent-posts{
  background: transparent url(images/sidebar-titles/dynamic-sidebar.png) 0 0 no-repeat !important;
}
#sidebar-twitter-tools span{display: none;}
#sidebar-twitter-tools{
  background: transparent url(images/sidebar-titles/dynamic-sidebar.png) 0 -41px no-repeat !important;
}
#sidebar-categories span{display: none;}
#sidebar-categories{
  background: transparent url(images/sidebar-titles/dynamic-sidebar.png) 0 -82px no-repeat !important;
}
#sidebar-archives span{display: none;}
#sidebar-archives{
  background: transparent url(images/sidebar-titles/dynamic-sidebar.png) 0 -123px no-repeat !important;
}
#sidebar-links span{display: none;}
#sidebar-links{

  background: transparent url(images/sidebar-titles/dynamic-sidebar.png) 0 -164px no-repeat !important;
}
</code></pre>
<p>That is all there is, you can see the results on the page you are reading.<br />
I found these articles/sites helpful:</p>
<ul>
<li> <a href=" http://wordpress.org/support/topic/206194" title="Dynamic Widget Classes for use in CSS" alt="Dynamic Widget Classes for use in CSS">Dynamic Widget Classes for use in CSS</a></li>
</ul>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F02%2Fstyling-wordpress-dynamic-sidebar-dynamic_sidebar_params-filter%2F&amp;linkname=Styling%20Wordpress%20Dynamic%20Sidebar%20%26%238211%3B%20dynamic_sidebar_params%20Filter"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/02/styling-wordpress-dynamic-sidebar-dynamic_sidebar_params-filter/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Wordpress &#8211; Use NextGen Gallery Code Inside an Excerpt</title>
		<link>http://www.mummey.org/2009/02/wordpress-use-nextgen-gallery-code-inside-an-excerpt/</link>
		<comments>http://www.mummey.org/2009/02/wordpress-use-nextgen-gallery-code-inside-an-excerpt/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:48:19 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[nextgen]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=147</guid>
		<description><![CDATA[One problem with the ways that Wordpress handles excerpt is that it always strips the HTML out. This is fine for most casual bloggers but when you are really trying to customize something for a client, it simply doesn&#8217;t cut it. What we wanted to do was use some of the NextGen Gallery markdown code [...]]]></description>
			<content:encoded><![CDATA[<p>One problem with the ways that Wordpress handles excerpt is that it always strips the HTML out. This is fine for most casual bloggers but when you are really trying to customize something for a client, it simply doesn&#8217;t cut it. What we wanted to do was use some of the NextGen Gallery markdown code in the &#8220;Excerpt&#8221; box of the post and have Wordpress render this in the category archive.</p>
<p>After some initial research I discovered that this markdown code is called &#8220;shortcode&#8221; in WP terminology. They have a whole <a href="http://codex.wordpress.org/Shortcode_API">Shortcode API</a>. Now it was just a matter of finding the correct functions to get the shortcode to render.</p>
<p>I wanted to create a special template for the category, essentially a <strong>photo blog</strong>, so that it would look different from the other categories. This is pretty straightforward, just create a new file called category-<em>id</em>.php, where <em>id</em> is the id number of your category. In my case it was category-40.php. The next step was to copy all the code from category.php and paste it into category-40.php.</p>
<p>When displaying the post&#8217;s excerpt, Wordpress uses a function called <strong>the_excerpt()</strong>. Here it is in the default sandbox template:</p>
<pre><code class="php">
the_excerpt(''.__('Read More &lt;span class="meta-nav"&gt;&amp;raquo;&lt;/span&gt;', 'sandbox').'') ;
</code></pre>
<p>The problem with the_excerpt is that is echoes the excerpt directly to the screen. In order to return the excerpt value as a string we need to use <strong>get_the_excerpt()</strong>. Next after checking the shortcode API, I discovered a function that will run all the shortcodes on a given string and return the output as a string, <strong>do_shortcode()</strong>.</p>
<p>So all we need to do now is combine these two functions, and move it into the template:</p>
<pre><code>
echo do_shortcode(get_the_excerpt());
</code></pre>
<p>And there it is!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F02%2Fwordpress-use-nextgen-gallery-code-inside-an-excerpt%2F&amp;linkname=Wordpress%20%26%238211%3B%20Use%20NextGen%20Gallery%20Code%20Inside%20an%20Excerpt"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/02/wordpress-use-nextgen-gallery-code-inside-an-excerpt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>First Wordpress Theme &#8211; My Development Toolbox</title>
		<link>http://www.mummey.org/2009/02/first-wordpress-theme-my-development-toolbox/</link>
		<comments>http://www.mummey.org/2009/02/first-wordpress-theme-my-development-toolbox/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 14:04:47 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[blueprint]]></category>
		<category><![CDATA[coda]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=66</guid>
		<description><![CDATA[My friend Andy recently asked me to help him redesign his website. He runs fly fishing tours here in Mongolia and wasn&#8217;t happy with his current site design. He recently switched most of his websites from Joomla! over to Wordpress. When he came to me with the request I was very excited to help as [...]]]></description>
			<content:encoded><![CDATA[<p>My friend Andy recently asked me to help him redesign his website. He runs fly fishing tours here in Mongolia and wasn&#8217;t happy with his current site design. He recently switched most of his websites from Joomla! over to Wordpress. When he came to me with the request I was very excited to help as most of my templating/design experience has been strictly for Joomla! or custom projects, I had yet to really delve into creating a Wordpress theme. During the whole process I learned quite a bit about the inner workings of Wordpress and have already applied this knowledge to working on my own blog (and hopefully soon designing a theme for mummey.org). Another thing that surprised me was how straightforward the whole process was, there are so many great tools and plugins for Wordpress that we encountered very few problems throughout the design process.</p>
<p>But before starting any programming or design process, it is important to have a good set of tools and resources at your disposal. So the main purpose of this post is to detail most of the tools I used that may help you along with designing your own Wordpress theme.</p>
<h3 class="children">Code Base</h3>
<ul class="list-no-style">
<li>
<div id="attachment_96" class="wp-caption alignleft" style="width: 160px"><a href="http://www.plaintxt.org/themes/sandbox/" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/sandbox-c2b7-plaintxtorg-1-150x91.jpg" alt="Wordpress Sandbox" title="sandbox-c2b7-plaintxtorg-1" width="150" height="91" class="size-thumbnail wp-image-96" /></a><p class="wp-caption-text">Wordpress Sandbox</p></div><br />
<a href="http://www.plaintxt.org/themes/sandbox/" title="Wordpress Sandbox" target="_blank">Wordpress Sandbox</a> &#8211; The starting point for my theme. This is a great template that you can just add some formatting and customization and has almost all the functions you need to make a great template.
</li>
</ul>
<h3 class="children">Development Tools</h3>
<ul class="list-no-style">
<li>
<div id="attachment_77" class="wp-caption alignleft" style="width: 130px"><a href="http://www.panic.com" target="_blank"><img class="size-full wp-image-77" title="panic-shockingly-good-mac-software" src="http://www.mummey.org/wp-content/uploads/2009/02/panic-shockingly-good-mac-software.jpg" alt="Coda by Panic" width="120" height="124" /></a><p class="wp-caption-text">Coda by Panic</p></div><br />
<a title="Coda" href="http://www.panic.com" target="_blank">Coda</a> &#8211; I have tried quite a few IDEs and I have found anything that I enjoy working with more than Coda. Everything just seems to flow really well and some some great features like integrated SVN, a great FTP utility, SSH terminal and a lot more. I feel that it is a steal at only 99$.
</li>
<li>
<div id="attachment_115" class="wp-caption alignleft" style="width: 160px"><a href="http://getfirebug.com/" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/firebug-web-development-evolved-150x150.jpg" alt="Firebug" title="firebug-web-development-evolved" width="150" height="150" class="size-thumbnail wp-image-115" /></a><p class="wp-caption-text">Firebug</p></div><br />
<a title="Firebug" href="http://getfirebug.com/" target="_blank">Firebug</a> &#8211; Firebug is a must have for any web developer. It gives you a very detailed look at webpages including the DOM, CSS, JS, HTML and also has a handy inspector for helping to solve formatting issues. I often use it to just quickly play around with different color and formatting values to find ones that work.
</li>
</ul>
<h3 class="children">Javascript and CSS</h3>
<ul class="list-no-style">
<li>
<div id="attachment_79" class="wp-caption alignleft" style="width: 160px"><a href="http://www.blueprintcss.org/" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/blueprint_-a-css-framework-spend-your-time-innovating-not-replicating-150x92.jpg" alt="Blueprint CSS" title="blueprint_-a-css-framework-spend-your-time-innovating-not-replicating" width="150" height="92" class="size-thumbnail wp-image-79" /></a><p class="wp-caption-text">Blueprint CSS</p></div><br />
<a href="http://www.blueprintcss.org/" title="Blueprint CSS Framework" target="_blank">Blueprint CSS Framework</a> &#8211; I would say that most of the projects I do a lot of custom design work, I try to incorporate Blueprint. It is a great start for anyone wanting to make clean, multicolumn layouts. It also takes care of a lot of spacing and typography for you and works with IE6 too.
</li>
<li>
<div id="attachment_85" class="wp-caption alignleft" style="width: 160px"><a href="http://www.jquery.com" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/jquery_-the-write-less-do-more-javascript-library-150x77.jpg" alt="jQuery JS Library" title="jquery_-the-write-less-do-more-javascript-library" width="150" height="77" class="size-thumbnail wp-image-85" /></a><p class="wp-caption-text">jQuery JS Library</p></div><br />
<a href="http://www.jquery.com" title="jQuery" target="_blank">jQuery</a> &#8211; There isn&apos;t much to say about jQuery that hasn&#8217;t already been said. It is the best JS framework out there and with the new release a lot of new features have been added.
</li>
<li>
<div id="attachment_88" class="wp-caption alignleft" style="width: 160px"><a href="http://code.google.com/apis/ajaxlibs/" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/ajax-libraries-api-google-code-150x99.jpg" alt="Google Ajax Libraries" title="ajax-libraries-api-google-code" width="150" height="99" class="size-thumbnail wp-image-88" /></a><p class="wp-caption-text">Google Ajax Libraries</p></div><br />
<a href="http://code.google.com/apis/ajaxlibs/" title="Google Ajax Libraries" target="_blank">Google Ajax Libraries</a> &#8211; This service offered by Google allows you to let them host your javascript/ajax libraries rather than you having to host them. From the site <i>&#8220;We take the pain out of hosting the libraries, correctly setting cache headers, staying up to date with the most recent bug fixes, etc. &#8220;</i>
</li>
<li>
<div id="attachment_111" class="wp-caption alignleft" style="width: 160px"><a href="http://users.tpg.com.au/j_birch/plugins/superfish/#getting-started" target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/superfish-suckerfish-on-_roids-2.jpg" alt="Superfish" title="superfish-suckerfish-on-_roids-2" width="150" height="80" class="size-full wp-image-111" /></a><p class="wp-caption-text">Superfish</p></div><br />
<a href="http://users.tpg.com.au/j_birch/plugins/superfish/#getting-started" title="Superfish" target="_blank">Superfish</a> &#8211; This is a very cool dropdown menu that uses my favorite javascript framework jQuery. It is very similar to the previous iteration, S.ckerfish, but has some more options and it was very easy to implement into my wordpress template. I also like the support for IE6!</li>
</ul>
<h3 class="children">Other Tools</h3>
<ul class="list-no-style">
<li>
<div id="attachment_118" class="wp-caption alignleft" style="width: 160px"><a href="http://fireftp.mozdev.org/"  target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/fireftp-the-free-ftp-client-for-mozilla-firefox.jpg" alt="Fireftp" title="fireftp-the-free-ftp-client-for-mozilla-firefox" width="150" height="139" class="size-full wp-image-118" /></a><p class="wp-caption-text">Fireftp</p></div><br />
<a href="http://fireftp.mozdev.org/" title="Fireftp" target="_blank">Fireftp</a> &#8211; This is a lightweight, easy to use firefox plugin that has a bunch of great features found in stand alone FTP programs. I like it mainly because it just sits as a tab in my browser and I don&#8217;t need to mess around with some other FTP program. You can also store and name all of your connections for easy retrieval.
</li>
<li>
<div id="attachment_120" class="wp-caption alignleft" style="width: 160px"><a href="http://skitch.com/"  target="_blank"><img src="http://www.mummey.org/wp-content/uploads/2009/02/skitchcom-skitch-fast-and-fun-screen-capture-and-image-sharing-150x133.jpg" alt="Skitch" title="skitchcom-skitch-fast-and-fun-screen-capture-and-image-sharing" width="150" height="133" class="size-thumbnail wp-image-120" /></a><p class="wp-caption-text">Skitch</p></div><br />
<a href="http://skitch.com/" title="Skitch" target="_blank">Skitch</a> &#8211; A fantastic screen capture program. Skitch is one of the most well designed programs I have ever used. It has a great user interface and is very useful for taking screen captures. There are also some great tools to add some graphics and text on top of your screen caps. I tend to use this program a lot during my development, especially when I need to send prototype images to my clients.
</li>
</ul>
<p><br class="children"/></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F02%2Ffirst-wordpress-theme-my-development-toolbox%2F&amp;linkname=First%20Wordpress%20Theme%20%26%238211%3B%20My%20Development%20Toolbox"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/02/first-wordpress-theme-my-development-toolbox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I was on CNN!</title>
		<link>http://www.mummey.org/2009/02/i-was-on-cnn/</link>
		<comments>http://www.mummey.org/2009/02/i-was-on-cnn/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 05:57:20 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[mongolia]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[cnn]]></category>
		<category><![CDATA[super bowl]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=53</guid>
		<description><![CDATA[I just received an email from one of my old Peace Corps friends who lives in D.C. and she said that she saw me on TV yesterday. There was a big (by mongolian standards) party at <a href="http://www.gk-irishpub.mn/eng/about.php">Grand Khan Irish Pub</a> for the superbowl. Me and some buddies woke up early so we could catch the game. I was quite surprised to see so many people, especially Mongolians who were totally hyped about the game.]]></description>
			<content:encoded><![CDATA[<p>I just received an email from one of my old Peace Corps friends who lives in D.C. and she said that she saw me on TV yesterday. There was a big (by mongolian standards) party at <a href="http://www.gk-irishpub.mn/eng/about.php">Grand Khan Irish Pub</a> for the superbowl. Me and some buddies woke up early so we could catch the game. I was quite surprised to see so many people, especially Mongolians who were totally hyped about the game. While I was there a reporter I knew gave me an interview for the AP. Little did I know it would wind up on CNN.<br />
Life goal #64 &#8211; 15 Seconds of fame. CHECK!<br />
<br/><br />
<br/></p>
<div style="text-align:center">
<object width="450" height="370"><param name="movie" value="http://www.ireport.com/themes/custom/resources/swfplayer/mediaplayer.swf"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="flashvars" value="height=370&#038;width=448&#038;autostart=false&#038;autoscroll=false&#038;showstop=false&#038;showicons=false&#038;showdigits=total&#038;controlbar=34&#038;backcolor=0xFFFFFF&#038;screencolor=0x000000&#038;frontcolor=0xDEDEDE&#038;lightcolor=0x00A2FF&#038;logo=http%3A//www.ireport.com/themes/custom/resources/swfplayer/data/images/ireport_wm.gif&#038;file=http%3A//ht.cdn.turner.com/ireport/big/prod/2009/02/03/WE00204434/409829/Anon1233721693-SuperBowlPartyInMongolia510562.flv&#038;image=http%3A//i.cdn.turner.com/ireport/sm/prod/2009/02/03/WE00204434/409829/Anon1233721693-SuperBowlPartyInMongolia510562_lg.jpg"></param><embed src="http://www.ireport.com/themes/custom/resources/swfplayer/mediaplayer.swf" type="application/x-shockwave-flash" wmode="transparent" width="450" height="370" menu="false" flashvars="height=370&#038;width=448&#038;autostart=false&#038;autoscroll=false&#038;showstop=false&#038;showicons=false&#038;showdigits=total&#038;controlbar=34&#038;backcolor=0xFFFFFF&#038;screencolor=0x000000&#038;frontcolor=0xDEDEDE&#038;lightcolor=0x00A2FF&#038;logo=http%3A//www.ireport.com/themes/custom/resources/swfplayer/data/images/ireport_wm.gif&#038;file=http%3A//ht.cdn.turner.com/ireport/big/prod/2009/02/03/WE00204434/409829/Anon1233721693-SuperBowlPartyInMongolia510562.flv&#038;image=http%3A//i.cdn.turner.com/ireport/sm/prod/2009/02/03/WE00204434/409829/Anon1233721693-SuperBowlPartyInMongolia510562_lg.jpg"></embed></object></div>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F02%2Fi-was-on-cnn%2F&amp;linkname=I%20was%20on%20CNN%21"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/02/i-was-on-cnn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dashboards, Web Reporting and Business Intelligence (BI)</title>
		<link>http://www.mummey.org/2009/02/dashboards-web-reporting-and-business-intelligence-bi/</link>
		<comments>http://www.mummey.org/2009/02/dashboards-web-reporting-and-business-intelligence-bi/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 04:04:29 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[featured articles]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[Dashboard]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[oss]]></category>
		<category><![CDATA[pentaho]]></category>
		<category><![CDATA[Reporting]]></category>
		<category><![CDATA[Web Reporting]]></category>
		<category><![CDATA[ws02]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=33</guid>
		<description><![CDATA[Obviously web reporting is nothing really new; one basic approach is this:

Aggregate your data and output it in some kind of structured format, usually XML
Request this information and generate some visualizations of it
Serve these visualizations through a web server

Pretty basic stuff. All of the tools that I have seen essentially make one or all of [...]]]></description>
			<content:encoded><![CDATA[<p>Obviously web reporting is nothing really new; one basic approach is this:</p>
<ol>
<li>Aggregate your data and output it in some kind of structured format, usually XML</li>
<li>Request this information and generate some visualizations of it</li>
<li>Serve these visualizations through a web server</li>
</ol>
<p>Pretty basic stuff. All of the tools that I have seen essentially make one or all of these processes easier. Unfortunately no matter what tools you choose, the rule of engineering stands: Fast, cheap, good &#8211; choose two</p>
<p>In this context it is more like: Less proprietary code, free software, easy to use/maintain &#8211; choose two. The good news is that all of the solutions described essentially have the same result: a web dashboard. The choice that needs to be made, is where you want to go with it? In the spirit of Enterprise software the clear winner is the solution with NO proprietary code, easy to use interfaces, and maybe some support.The biggest obstacle in this model is step 1, data aggregation and standardization.</p>
<p>Step 1 may involve lots of substeps that require some substantial development work including:</p>
<ol>
<li>Connecting to various datasources</li>
<li>Writing queries to retrieve the data</li>
<li>Parsing the data into XML (or some other standardized format)</li>
<li>If interaction is needed, the data aggregator will also need to accept inputs and query dynamically</li>
</ol>
<p>The issue is that all of these steps may differ among various datasources like oracle, csv, excel, etc. And yes, there are plenty of tools to help with this step. The main point though is that no matter what solution you choose, there will a substantial portion of development time needed for Step 1; even with a GUI you still need to write queries. It is really up to you if you want to follow this model and incur development time, however for an &#8220;executive&#8221; dashboard I feel it essential to follow this model.</p>
<p>The solutions I found can be divided into 2 categories: Web Reporting and Business Intelligence (BI). Web Reporting covers the basic aspects of the above model and nothing more; whereas the above model is just a subset of what  Business Intelligence can do. One thing to remember also is that its always &#8220;pay to play&#8221; with the support for the free solutions. They&#8217;ll give you the software, but you need to pay for their help. Also I tried to chose solutions whose free software should have all the features we need.</p>
<h3 class="children">Web Reporting Solutions</h3>
<ul class="list-no-style">
<li>
<div id="attachment_38" class="wp-caption alignleft" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/open-flash-charts.jpg" rel="lightbox"><img src="http://www.mummey.org/wp-content/uploads/2009/02/open-flash-charts-150x150.jpg" alt="Open Flash Charts Pie Chart" title="open-flash-charts" width="150" height="150" class="size-thumbnail wp-image-38" /></a><p class="wp-caption-text">Open Flash Charts Pie Chart</p></div><br />
1. <a title="Open Flash Chart" href="http://teethgrinder.co.uk/open-flash-chart/" target="_blank">Open Flash Chart</a> &#8211; The simplest, (cheapest?) and fastest way to get some dashboards is to just write some code. If we are only connecting to one database, no problem using some free tools like Open Flash Chart. It is the simplest because we don&#8217;t really need to abstract any data, so step 1 processes are minimized. However it isn&#8217;t Enterprise level and makes big assumptions on the sources and format of the data. Any changes to the model will require code edits and support calls which doesn&#8217;t make for good sustainability.
</li>
<li>
<div id="attachment_44" class="wp-caption alignright" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/open-flash-charts2.jpg" rel="lightbox"><img src="http://www.mummey.org/wp-content/uploads/2009/02/open-flash-charts2-150x150.jpg" alt="Open Flash Charts - Area Chart" title="open-flash-charts2" width="150" height="150" class="size-thumbnail wp-image-44" /></a><p class="wp-caption-text">Open Flash Charts - Area Chart</p></div><br />
2. <a title="WS02 Web Application Service" href="http://wso2.org/projects/wsas/java" target="_blank">WSO2 Web Application Server</a> + <a title="Open Flash Chart" href="http://teethgrinder.co.uk/open-flash-chart/" target="_blank">Open Flash Chart</a> &#8211; This combination is a little more enterprise. The tools are still free, which is great. The Web Application Server can handle step 1 pretty well and has a nice GUI interface to make all the data connections and output some XML as a web service, definitely enterprise level. However we still need a small middleware layer to accept the XML and generate the flash charts which require less (but still some) proprietary code as the first option. The only code changes that would be needed would be if you wanted say different charts, or a different layout, but could probably be done by someone with some basic HTML and scripting knowledge.
</li>
<li>
<div id="attachment_42" class="wp-caption alignleft" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/xcelsius.jpg"><img src="http://www.mummey.org/wp-content/uploads/2009/02/xcelsius-150x150.jpg" alt="SAP Xcelsius Dashboard" title="xcelsius" width="150" height="150" class="size-thumbnail wp-image-42" /></a><p class="wp-caption-text">SAP Xcelsius Dashboard</p></div><br />
3. <a title="WS02 Web Application Service" href="http://wso2.org/projects/wsas/java" target="_blank">WSO2 Web Application Server</a> + <a title="Excelsius Engage" href="http://www.sap.com/solutions/sapbusinessobjects/sme/xcelsius/xcelsiusengage/index.epx" target="_blank">SAP Excelsius Engage</a> &#8211; This combination is fully enterprise level. It could probably bet set up with no proprietary coding at all. Excelsius is stand alone program that allows one to graphically design the dashboards and connect them up with various datasources. The only problem is that it costs a minimum of $1000, and for the server edition (which I feel is unnecessary) could be as much as $5000. So that may be out of budget. But it does produce beautiful results.
</li>
</ul>
<p><br class="children"/></p>
<h3>Business Intelligence Solutions</h3>
<p>I had never heard of Business Intelligence until I started doing research for this project. The best way I can describe it is that is a huge web based platform that seems to do everything. First off it has something called Data Integration. This is a very cool program that will not only aggregate different data sources, but allow you to transform among the datasources and output to pretty much anything. For example I could query an Oracle table and an Excel Sheet, aggregate those two into one dataset perform some transformation like sorting or pivoting and then output the result to a MySQL table. Its actually quite amazing. All of these data integrations can be set up as jobs that can be run in batch or run from command or run from some web service. From there it also includes a Web BI Platform, which is kinda like a portal that can show reports, dashboards, tables, basically anything and also has some admin for user control and permissions. It also includes tools to design and build reports and dashboards. It can also do complex analysis and data mining and will probably take out your trash and wash your car too.</p>
<p>Anyways, the benefits are intense, but may be a bit overkill if you just want a dashboard. Things this complicated can quickly turn from dream to nightmare however with these BI solutions almost all aspects can be managed through GUI tools. The real problem is that it will take a serious commitment to make it work because of its complexity. I am not sure they are the right solution for you, but maybe you will think of something else that it may be useful for.</p>
<ul class="list-no-style">
<li>
<div id="attachment_45" class="wp-caption alignleft" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/pentaho.jpg"><img src="http://www.mummey.org/wp-content/uploads/2009/02/pentaho-150x150.jpg" alt="Pentaho Dashboard" title="pentaho" width="150" height="150" class="size-thumbnail wp-image-45" /></a><p class="wp-caption-text">Pentaho Dashboard</p></div><br />
1. <a title="Pentaho BI Suite" href="http://www.pentaho.com/" target="_blank">Pentaho</a> &#8211; A free, open source collection of BI tools. Again with the &#8220;pay to play&#8221; support. Pentaho offers all of the functions specified above and has GUI tools for managing all of them. I was able to actually install Pentaho and was able to generate some reports, however it was quite difficult to configure the server and generating my own dashboard required some very complex configuration. But the data integration tool was stellar, I think on its own it is a very powerful tool that could be used outside the scope of the BI platform.
</li>
<li>
<div id="attachment_46" class="wp-caption alignright" style="width: 160px"><a href="http://www.mummey.org/wp-content/uploads/2009/02/websphere.jpg"><img src="http://www.mummey.org/wp-content/uploads/2009/02/websphere-150x150.jpg" alt="IBM Websphere Dashboard" title="websphere" width="150" height="150" class="size-thumbnail wp-image-46" /></a><p class="wp-caption-text">IBM Websphere Dashboard</p></div><br />
2. <a title="IBM Websphere" href="http://www-01.ibm.com/software/genservers/portal/dashboardframework/" target="_blank">IBM Websphere</a> &#8211; I read all the papers for this but wasn&#8217;t actually able to try it out. But it is a huge system that probably does everything and I won&#8217;t even talk about it more because it probably costs many thousands. But it is a good basis to see what can be done.
</li>
</ul>
<p><br class="children"/><br />
Unless you see other potential value in implementing a BI system, I would say that option 3 under the web reporting is the best bet if you can spring for the software and development costs.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2009%2F02%2Fdashboards-web-reporting-and-business-intelligence-bi%2F&amp;linkname=Dashboards%2C%20Web%20Reporting%20and%20Business%20Intelligence%20%28BI%29"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2009/02/dashboards-web-reporting-and-business-intelligence-bi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cSprites &#8211; A Dynamic CSS Sprite Generator in PHP5</title>
		<link>http://www.mummey.org/2008/12/csprites-a-dynamic-css-sprite-generator-in-php5/</link>
		<comments>http://www.mummey.org/2008/12/csprites-a-dynamic-css-sprite-generator-in-php5/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 09:33:24 +0000</pubDate>
		<dc:creator>Adrian Mummey</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[sprite]]></category>

		<guid isPermaLink="false">http://www.mummey.org/?p=12</guid>
		<description><![CDATA[CSS Sprites &#8211; A Background
The idea of combining images into a larger one and displaying this using CSS tricks has been around for awhile. There are a couple big benefits to doing this: First it reduces the number of HTTP requests that the browser has to make, by combining say 5 images into 1 big [...]]]></description>
			<content:encoded><![CDATA[<h2>CSS Sprites &#8211; A Background</h2>
<p>The idea of combining images into a larger one and displaying this using CSS tricks has been around for <a href="http://www.alistapart.com/articles/sprites/">awhile</a>. There are a couple big benefits to doing this: First it reduces the number of HTTP requests that the browser has to make, by combining say 5 images into 1 big image, the number of image requests has been reduced by 4. This can <a href="http://css-tricks.com/css-sprites-what-they-are-why-theyre-cool-and-how-to-use-them/">increase the effeciency of page loading </a>and you can see gains in the speed at which your page is loaded. Second, when working with elements like rollover images, you can &#8220;preload&#8221; all of the states of the rollover and prevent flicker when users interact with these elements.</p>
<p>If used properly combining image elements in sprites can be very beneficial for web developers. However it is not without its problems. One of the most obvious issues is that the sprite needs to be generated before its component images can be used, <em>you need to know which images will be used beforehand.</em> This is fine for things like icons and buttons that won&#8217;t change very often, but is useless for any other images that will be displayed dynamically. Although it is good for very static elements like buttons and icons, if you need to make a change to any of these image elements, the entire sprite needs to be rebuilt, <em>the sprite AND CSS needs to be rebuilt to reflect any change to its component images</em>. Although there exist some scripts and websites that can handle this, it can still be a tedious process.</p>
<h2>cSprites &#8211; A New Way of Doing Things</h2>
<p>What cSprites aims to do is to solve these problems by generating CSS sprites on the fly. The general process of doing this consists of three steps:</p>
<ol>
<li>Tell cSprites which images you want to use</li>
<li>Process the sprites</li>
<li>Use cSprites functions to display the images and relevant CSS code</li>
</ol>
<p>Here is a sample of code that shows how these three steps are implemented:</p>
<pre><code class="html">
&lt;?php
//We need to include the main Sprite File which will setup the autoloading and config
require_once(&#39;Sprite.php&#39;);
Sprite::ppRegister(&#39;/images/image1.jpg&#39;);
Sprite::ppRegister(&#39;/images/image2.jpg&#39;);
Sprite::process(); //We MUST call the process function BEFORE we actually show any images
?&gt;
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
        &lt;?php echo Sprite::getAllCssInclude(); /*This will output the complete css of all of the sprites*/ ?&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php echo Sprite::image_tag(&#39;/images/image1.jpg&#39;); /*outputs a pseudo img tag using css styles*/ ?&gt;
&lt;?php echo Sprite::image_tag(&#39;/images/image2.jpg&#39;); /*outputs a pseudo img tag using css styles*/ ?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<h2>Get cSprites with SVN</h2>
<p><code class="simplecode">svn co https://csprites.svn.sourceforge.net/svnroot/csprites csprites </code></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.mummey.org%2F2008%2F12%2Fcsprites-a-dynamic-css-sprite-generator-in-php5%2F&amp;linkname=cSprites%20%26%238211%3B%20A%20Dynamic%20CSS%20Sprite%20Generator%20in%20PHP5"><img src="http://www.mummey.org/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.mummey.org/2008/12/csprites-a-dynamic-css-sprite-generator-in-php5/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
