<?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>The Code Dojo &#187; Benjam</title>
	<atom:link href="http://dojo.codegreene.com/author/benjam/feed/" rel="self" type="application/rss+xml" />
	<link>http://dojo.codegreene.com</link>
	<description>The Code Dojo is the veritable repository of random musings from the development team at Code Greene.</description>
	<lastBuildDate>Fri, 20 Jan 2012 18:09:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Restructuring a flat MPTT array into a tree array</title>
		<link>http://dojo.codegreene.com/2011/06/restructuring-a-flat-mptt-array-into-a-tree-array/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=restructuring-a-flat-mptt-array-into-a-tree-array</link>
		<comments>http://dojo.codegreene.com/2011/06/restructuring-a-flat-mptt-array-into-a-tree-array/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 03:50:25 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=661</guid>
		<description><![CDATA[I have a flat MPTT array (really any tree ordered array will work, not necessarily an MPTT array) which has it&#8217;s elements output in order as follows: Top Parent 1 Child 1-1 Child 1-2 Sub-Child 1-2-1 Sub-Child 1-2-2 Child 1-3 Top Parent 2 Child 2-1 &#8230; Each element is it&#8217;s own entry in the one [...]]]></description>
			<content:encoded><![CDATA[<p>I have a flat <acronym title="Modified Pre-ordered Tree Traversal">MPTT</acronym> array (really any tree ordered array will work, not necessarily an MPTT array) which has it&#8217;s elements output in order as follows:</p>
<ul>
<li>Top Parent 1</li>
<li>Child 1-1</li>
<li>Child 1-2</li>
<li>Sub-Child 1-2-1</li>
<li>Sub-Child 1-2-2</li>
<li>Child 1-3</li>
<li>Top Parent 2</li>
<li>Child 2-1</li>
<li>&#8230;</li>
</ul>
<p>Each element is it&#8217;s own entry in the one dimensional array.  This makes outputting that data in any kind of readable form very difficult, where keeping track of parents and branches are required in order to make sense of it.  This gets pretty messy, pretty quickly.  And the deeper the tree, the more complicated the process.</p>
<p>To make this easier to deal with, the array should be built in a tree format as follows:</p>
<ul>
<li>Top Parent 1
<ul>
<li>Child 1-1</li>
<li>Child 1-2
<ul>
<li>Sub-Child 1-2-1</li>
<li>Sub-Child 1-2-2</li>
</ul>
</li>
<li>Child 1-3</li>
</ul>
</li>
<li>Top Parent 2
<ul>
<li>Child 2-1</li>
<li>&#8230;</li>
</ul>
</li>
</ul>
<p>Where the children of the elements in the tree are actually children of the elements in the array.</p>
<p>In order to do this quickly and painlessly, we are going to parse through this array twice&#8230; no iterations, just a couple of foreach loops and we&#8217;ll get our tree exactly how we want it.</p>
<p>In order to do this, we must first make sure our array indexes are the same as the IDs of the items we are sorting (because we are pulling this from a database, right?).</p>
<p>To do this in CakePHP we run it through the Set::combine function like so:<br />
<code>Set::combine($tree_data, '/Model/id', '/.');</code></p>
<p>If you are not using CakePHP, you can create a new array, and as you foreach through your original array, set elements in the new array accordingly:<br />
<code>
<pre>
$old_tree_data = $tree_data;
$tree_data = array( );
foreach ($old_tree_data as $node) {
	$tree_data[$node['Model']['id']] = $node;
}
</pre>
<p></code></p>
<p>Now that we have our array indexes set to our model ID, we can proceed.</p>
<p>The trick to this method is not to move the nodes around, because if we did that, we&#8217;d still have to keep track of what went where, and that&#8217;s exactly what we&#8217;re trying to avoid.  Instead, we&#8217;re going to use references to keep track of our data as it gets moved around.  That way we still have our original base array element that we can play with without having to know where it actually is in the tree.</p>
<p>Here is the code, and then we&#8217;ll go through it and explain.<br />
<code>
<pre>
foreach ($tree_data as $key =&gt; $node) {
	if ( ! $node['Model']['parent_id']) {
		continue;
	}

	if ( ! isset($tree_data[$node['Model']['parent_id']]['Child'])) {
		$tree_data[$node['Model']['parent_id']]['Child'] = array( );
	}

	$tree_data[$node['Model']['parent_id']]['Child'][] =&amp; $tree_data[$key];
}
</pre>
<p></code></p>
<p>Now to explain&#8230; We parse through the array and for each element, we first test the element to see if it has a parent, if it does not, we just skip it, there&#8217;s no need to go further.</p>
<p>We then check and see if the parent element has an index called &#8216;Child&#8217; and if it does not, we create one and set it as an array.</p>
<p>Then we do the magic.  We set the next item in the parent node&#8217;s Child element to the <em><strong>reference</strong></em> of the current node.  We don&#8217;t actually move the node.  So now if you look at the array, you&#8217;ll see two entries for the current node, one inside the parent element, and one that was the original in the flat array.</p>
<p><strong>WARNING</strong>: One thing to note here, is that we are not setting it to the reference of <code>$node</code>, but to the reference of <code>$tree_data[$key]</code>.  The reason for this is because if the element is referenced to <code>$node</code>, the next time through the loop, <strong>all</strong> of the referenced elements will also be set to the new value of <code>$node</code>, and we certainly don&#8217;t want that.</p>
<p>The magical part of this, is that no matter where the references end up, the original is still there to be modified.  So for instance if I have a branch path with IDs as follows: 12, 5, 13, 14&#8230; it doesn&#8217;t matter what that path is, I can still access the element with ID 14 by modifying <code>$tree_data[14]</code>.  So if element 14 has child nodes, I can place them in the tree by modifying <code>$tree_data[14]['Child']</code>, and wherever that node is actually supposed to be, it will get modified there as well.  That&#8217;s the beauty of references.</p>
<p>Now to clean up the array, we just parse through it once more, and clear out the original reference nodes (the ones that have parents):<br />
<code>
<pre>
foreach ($tree_data as $key =&gt; $node) {
	if ( ! empty($tree_data['Model']['parent_id']) {
		unset($tree_data[$key]);
	}
}
</pre>
<p></code></p>
<p>And that&#8217;s it! No messing around with paths&#8230; no iterative functions&#8230; just twice through an array (maybe three times), and it&#8217;s all sorted, compartmentalized, and pretty.</p>
<p>If you have other methods of getting your trees into a usable form, please let us know in the comments.  We love seeing how other people do things.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2011/06/restructuring-a-flat-mptt-array-into-a-tree-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why is coding so personal?</title>
		<link>http://dojo.codegreene.com/2010/02/why-is-coding-so-personal/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-is-coding-so-personal</link>
		<comments>http://dojo.codegreene.com/2010/02/why-is-coding-so-personal/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:26:57 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[coding style]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=448</guid>
		<description><![CDATA[I&#8217;ve been noticing that often times, when getting or giving feedback on code, or browsing my favorite programming forum, or just reading posts about programming, that people often get very emotional about their code. I was wondering why this is, and because I am not a psychologist, I&#8217;ll just give you my thoughts. Coding to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-477" title="Why is coding so personal?" src="http://dojo.codegreene.com/wp-content/uploads/2010/02/personal1.jpg" alt="Why is coding so personal?" width="520" height="150" /><br />
I&#8217;ve been noticing that often times, when getting or giving feedback on code, or browsing my favorite programming forum, or just reading posts about programming, that people often get very emotional about their code.  I was wondering why this is, and because I am not a psychologist, I&#8217;ll just give you my thoughts.</p>
<p>Coding to me is like creating art, and there&#8217;s a great quote that backs me up on this:</p>
<blockquote><p>Programming is an art form that fights back. —Unknown</p></blockquote>
<p>Because code is like art, I get very attached to my code, as well as my style of coding.  My code is like my baby, my something from nothing that wouldn&#8217;t be there if it weren&#8217;t for me. It&#8217;s just a bunch of characters on the screen that, from somewhere in the blue smoke, creates a function, or a game, or a website.  I have received criticism on my code (as everyone has), as well as given criticism on other&#8217;s code (as everyone has), and those times when I&#8217;ve received criticism on my code, depending on how it was delivered, or what was said, it was almost like a personal attack on me.  And I&#8217;ve noticed a few other coders react the same way to criticisms on their code.  It&#8217;s like the person who called your code ugly or inelegant was saying that your child was ugly (and those of you who have kids know&#8230; that&#8217;s a huge no-no, punishable by any means available).</p>
<p>It may be because I think that my coding style is the best, it&#8217;s what I&#8217;m used to, and it&#8217;s the format I use because it&#8217;s the easiest for me to get at the information I need as fast as possible.  I know this because I&#8217;ve tried other styles (sometimes flipping back and forth in the same day), and looking at someone else&#8217;s code that uses a different style from me, is often times hard to peruse easily.  It&#8217;s what I like, and sometimes I have to hold myself back from reformatting code I come across into my own style.</p>
<p>So maybe we should stop thinking of code and coding styles as being &#8220;right&#8221; or &#8220;wrong&#8221;, and think of them more like the tool that they are, a means to an end.  And the way you react to someone else&#8217;s means should be a little more like a suggestion for a different method of painting.  Not a matter of fact, but just another tool for the tool box.</p>
<p>To continue the art analogy, it&#8217;s like everybody is given all the art supplies in the world, and told to make/paint/draw/create a box.  Everyone will come up with a different way of doing it, some will be huge and bright red; others will be small and drawn in pencil; others still might be made of clay or brick.  No matter what, it&#8217;s the way you chose to do it, and it&#8217;s no better or worse than the person&#8217;s next to you.  You might think so because yours was faster, fancier, more elegant, or more &#8220;boxy&#8221;; but they might think the opposite.  In the end, you still have a box, and so do they.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2010/02/why-is-coding-so-personal/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Redirecting to parent or child pages in WordPress</title>
		<link>http://dojo.codegreene.com/2010/01/redirecting-to-parent-or-child-pages-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=redirecting-to-parent-or-child-pages-in-wordpress</link>
		<comments>http://dojo.codegreene.com/2010/01/redirecting-to-parent-or-child-pages-in-wordpress/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 15:25:24 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[Usability]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[child]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[parent]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=402</guid>
		<description><![CDATA[A few of our projects here at Code Greene required the use of WordPress, and those projects had situations that I have since encountered in a site I built in WordPress for someone in my family. That situation was trying to redirect to a parent or child page when a certain page was clicked on. [...]]]></description>
			<content:encoded><![CDATA[<p>A few of our projects here at Code Greene required the use of WordPress, and those projects had situations that I have since encountered in a site I built in WordPress for someone in my family.  That situation was trying to redirect to a parent or child page when a certain page was clicked on.</p>
<p>I know that may seem a bit confusing, but let me give an example.  Say I have an &#8220;About&#8221; page, and that &#8220;About&#8221; page has three child pages; &#8220;Who I Am&#8221;, &#8220;What I Do&#8221;, and &#8220;Why I Do It&#8221;.  Now let&#8217;s also say that my &#8220;About&#8221; page doesn&#8217;t have any actual content, it&#8217;s just a container for the other three pages, and I just want to redirect my visitors to the &#8220;About | Who I Am&#8221; page without ever hitting the &#8220;About&#8221; page. Well, here&#8217;s how I do that.</p>
<p>First we need a page template that we can use for the &#8220;About&#8221; page that will do all the magic for us:</p>
<p>In a new file in your theme folder called redirect_down.php (you can really call it anything you want, this is what I used), put the following:</p>
<pre><code>
&lt;?php

/*
Template Name: Redirect Down
*/

// grab the direct children pages of this page
// (both child_of and parent are needed)
$sub_pages = get_pages(array('child_of' =&gt; $post-&gt;ID, 'parent' =&gt; $post-&gt;ID, 'sort_column' =&gt; 'menu_order', 'number' =&gt; 1));

$URI = get_permalink($sub_pages[0]-&gt;ID);

// redirect the user down one level in the tree
header('Location: '.$URI);

</code></pre>
<p>How this works is it finds the first child of the page you are on, grabs the URI for it, and redirects you to that page.</p>
<p>Now when I create my &#8220;About&#8221; page (the one with no content), I set my page template to &#8220;Redirect Down&#8221; in the template drop down, and voilà, when a visitor clicks on the &#8220;About&#8221; link, they automatically get redirected to the &#8220;About | Who I Am&#8221; page, no questions asked.  If I had pages under the &#8220;Who I Am&#8221; page, and it was just a container for those, I could also set my template for the &#8220;Who I Am&#8221; page to &#8220;Redirect Down&#8221;, and when my visitor clicked the &#8220;About&#8221; link, it would redirect to the &#8220;Who I Am&#8221; page, which would then redirect to the first child page.</p>
<p>To complete the collection&#8230; in one of the projects I worked on recently, we had a situation where if a child page link was clicked, we needed to redirect up the tree to the parent page.  This is basically the same thing, just the other direction, but also a bit easier to code.  Here is how it is achieved:</p>
<p>In a new file in your theme folder called redirect_up.php (again, you can call it anything you want, this is just what I used), put the following:</p>
<pre><code>
&lt;?php

/*
Template Name: Redirect Up
*/

// redirect the user up one level in the tree
$URI = rtrim($_SERVER['REQUEST_URI'], ' /');

$URI = substr($URI, 0, strrpos($URI, '/') + 1);

if ( ! in_array($URI, array('', '/'))) {
	header('Location: '.$URI);
}

</code></pre>
<p>The way this works, is it grabs the URI given, and simply removes the last directory from the URI.  (You could also find the parent ID from the <var>$post</var> data and use that to find the permalink, much like the previous template, but this works for what I needed it to do.)  If you have your permalinks set up properly, this should work beautifully.  And again, with this one, you can set it on as many pages as you want, redirecting all the way up the tree if you wish.</p>
<p>Hope this helps someone.  Let me know if it helped you in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2010/01/redirecting-to-parent-or-child-pages-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>&#8220;What does that do?&#8221; &#8211; Cake functions I&#8217;ve found</title>
		<link>http://dojo.codegreene.com/2009/05/what-does-that-do-cake-functions-ive-found/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-does-that-do-cake-functions-ive-found</link>
		<comments>http://dojo.codegreene.com/2009/05/what-does-that-do-cake-functions-ive-found/#comments</comments>
		<pubDate>Thu, 07 May 2009 22:17:27 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=290</guid>
		<description><![CDATA[In this episode of &#8220;What does that do?&#8221; we&#8217;re going to look at a few helpers and methods of (probably) well known classes that may or may not be that well known, as well as enlighten you to a few gotchas that I&#8217;ve discovered during my Cake usage. First is the Set::extract method. When I [...]]]></description>
			<content:encoded><![CDATA[<p>In this episode of &#8220;What does that do?&#8221; we&#8217;re going to look at a few helpers and methods of (probably) well known classes that may or may not be that well known, as well as enlighten you to a few gotchas that I&#8217;ve discovered during my Cake usage.</p>
<p>First is the <tt>Set::extract</tt> method.  When I first started using Cake, I was using the dot notation in my <tt>extract</tt> and <tt>combine</tt> calls, that is until I discovered the XPath notation that was also allowed which offers more control over your returned values.  One gotcha that I discovered early on, was that to emulate the dot notation <var>{n}.Foo</var>, you can&#8217;t just use <var>/Foo</var>, you have to add a <var>/.</var> to the end to make it work properly.  So you end up with <var>/Foo/.</var>.  One other thing I noticed while poking around in the source, was that the argument order for <tt>extract</tt> is opposite from that of <tt>combine</tt>.  With <tt>combine</tt>, you put <var>$data</var>, then <var>$path[12]</var>.  With <tt>extract</tt>, you put in <var>$path</var> first, then <var>$data</var>.  I was doing it wrong for a long time, but the Cake developers thought of this, and silently flip them in <tt>extract</tt> if you get them backwards.</p>
<p><span id="more-290"></span>Another method in <tt>Set</tt> that I never knew about, is <tt>enum</tt>.  With <tt>enum</tt>, you give it a value, and then a list to select from.  The cool thing is, if you don&#8217;t give it a select list, it defaults to yes/no.  I have used this many times since I discovered it.  I often use an active field in my models, and when outputting to my index pages, I would like to see Yes/No, instead of 1/0.  So I just wrap the output in <tt>Set::enum($value)</tt>, and it&#8217;s good to go.</p>
<p>Set has many methods that are really useful.  One that I haven&#8217;t used yet, but would if I needed it, is <tt>normalize</tt>.  I have a similar function in my little bag of tricks that I use in my own code.  What it does is takes a separated string, or an array, and converts them both to an array that has been trimmed.  One gotcha with this one is the <var>$assoc</var> argument (defaults to true).  If this is on and you feed it something like:</p>
<pre class="brush: php">
Set::normalize(&#039;This, is, my, list&#039;);
</pre>
<p>What you&#8217;ll get back is the following:</p>
<pre class="brush: php">
array(
	&#039;This&#039; =&gt; null,
	&#039;is&#039; =&gt; null,
	&#039;my&#039; =&gt; null,
	&#039;list&#039; =&gt; null
);
</pre>
<p>which is not what I was expecting the first time I ran this function.  What I was expecting was:</p>
<pre class="brush: php">
array(
	0 =&gt; &#039;This&#039;,
	1 =&gt; &#039;is&#039;,
	2 =&gt; &#039;my&#039;,
	3 =&gt; &#039;list&#039;
);
</pre>
<p>and to get that, just set <var>$assoc</var> to <tt>false</tt>:</p>
<pre class="brush: php">
Set::normalize(&#039;This, is, my, list&#039;, false);
</pre>
<p>A helper that I discovered recently is the <tt>number</tt> helper.  It doesn&#8217;t have many methods, but I&#8217;ve already used <tt>currency</tt> on more than one occasion, which adds commas and decimals as well as the dollar sign to the output.  It also has <tt>toReadableSize</tt>, which converts a raw file size in bytes to one in kB, MB, GB, etc. based on the size given.  There is a <tt>toPercentage</tt> method, which while it sounds like it might convert decimal numbers to a percentage (e.g.- 0.75 to 75%), all it does is round to the place you give it, and add a percentage sign on the end.  It would make more sense if it did the conversion to percentage as well, instead of just adding a percentage sign, but I digress.</p>
<p>A class that I hadn&#8217;t heard of until a colleague of mine cleaned up some of my code with it, is the <tt>HttpSocket</tt> class.  This class is really cool, it takes all that cURL type stuff, and then some, and wraps it all up in a nice little package.  The methods here that interest me the most are <tt>get</tt>, and <tt>post</tt>.  Both of which do pretty much what you would imagine them to do.</p>
<p>So there are a few of my new favorite unknown functions, what are some that you&#8217;ve discovered and now can&#8217;t live without?</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2009/05/what-does-that-do-cake-functions-ive-found/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filter images from WordPress &#x5b;gallery]</title>
		<link>http://dojo.codegreene.com/2009/05/filter-images-from-wordpress-gallery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=filter-images-from-wordpress-gallery</link>
		<comments>http://dojo.codegreene.com/2009/05/filter-images-from-wordpress-gallery/#comments</comments>
		<pubDate>Thu, 07 May 2009 15:46:40 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[Usability]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[gallery]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=259</guid>
		<description><![CDATA[EDIT: This post has been deprecated by the recently released WordPress 2.9. Please update your WordPress installation to get this functionality in your blog. If you don&#8217;t wish to update your blog software, then please continue reading. I was writing a post on my personal blog recently and wanted to show a gallery of pictures, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EDIT</strong>: This post has been deprecated by the recently released WordPress 2.9.  Please <a href="http://wordpress.org/download/">update your WordPress installation</a> to get this functionality in your blog.</p>
<p>If you don&#8217;t wish to update your blog software, then please continue reading.</p>
<hr />
<p>I was writing a post on my personal blog recently and wanted to show a gallery of pictures, but I also wanted to show one of those pictures near the top of the post, but not in the gallery, and if you&#8217;ve ever tried to do this with <tt>&#x5b;gallery]</tt>, you know it can&#8217;t be done.</p>
<p>Well, now it can, and I&#8217;ll show you how.</p>
<p><span id="more-259"></span>First we take a look at the original WP function that creates the gallery.  The function is called <tt>gallery_shortcode( )</tt> and it&#8217;s located in the <tt>/wp-includes/media.php</tt> file.  Make a copy of this function and paste it in your <tt>/wp-content/themes/[your_theme]/functions.php</tt> file, or create a plugin and paste it there.</p>
<p>Now that that&#8217;s pasted, lets take a look at it.</p>
<p>Near the top of the function, you&#8217;ll find the hook we&#8217;ll be using to modify the gallery function and output.  It looks like the following:</p>
<pre class="brush: php">
	// Allow plugins/themes to override the default gallery template.
	$output = apply_filters(&#039;post_gallery&#039;, &#039;&#039;, $attr);
	if ( $output != &#039;&#039; )
		return $output;
</pre>
<p>So the first thing we need to do is remove that portion from our function, because it doesn&#8217;t make any sense to hook a callback to itself.</p>
<p>The next thing we need to do is edit the function attributes to match the attributes in the hook. Here is the new function definition:</p>
<pre class="brush: php">
function my_gallery_shortcode($null, $attr = array( )) {
</pre>
<p>The <var>$null</var> attribute takes the empty string that gets passed and then just ignores it, we don&#8217;t need it here.  The <var>$args</var> attribute takes the <var>$attr</var> variable that gets passed.  you&#8217;ll also note that we renamed the function so we don&#8217;t get naming conflicts.  Just under the function, right after the closing brace ( } ), add the following:</p>
<pre class="brush: php">
add_filter(&#039;post_gallery&#039;, &#039;my_gallery_shortcode&#039;, 10, 2);
</pre>
<p>This hooks the function we&#8217;re creating into the original function and overrides it.</p>
<p>Now that we have that, we take a look at where the function is pulling it&#8217;s data from, so we can edit that data and filter the output to exclude certain images from the gallery.  Just under where the shortcode attributes are extracted, you&#8217;ll see a call to <tt>get_children( )</tt>.  This is the function that pulls the gallery image data from the database.  After looking through the source, I noticed there was an <var>exclude</var> attribute that was available to this function, but it wasn&#8217;t being used here.  This will be the key to fixing this function.</p>
<p>Add the <var>exclude</var> attribute to the <tt>get_children( )</tt> function call, and add it to the shortcode attribute extract portion of our function as well, so we get what we need out of the <var></var> shortcode and don&#8217;t discard it along the way.  Here is the new portion of the function, with a little bit of code before and after for orientation:</p>
<pre class="brush: php">
	// We&#039;re trusting author input, so let&#039;s at least make sure it looks like a valid orderby statement
	if ( isset( $attr[&#039;orderby&#039;] ) ) {
		$attr[&#039;orderby&#039;] = sanitize_sql_orderby( $attr[&#039;orderby&#039;] );
		if ( !$attr[&#039;orderby&#039;] )
			unset( $attr[&#039;orderby&#039;] );
	}

	extract(shortcode_atts(array(
		&#039;order&#039;      =&gt; &#039;ASC&#039;,
		&#039;orderby&#039;    =&gt; &#039;menu_order ID&#039;,
		&#039;id&#039;         =&gt; $post-&gt;ID,
		&#039;itemtag&#039;    =&gt; &#039;dl&#039;,
		&#039;icontag&#039;    =&gt; &#039;dt&#039;,
		&#039;captiontag&#039; =&gt; &#039;dd&#039;,
		&#039;columns&#039;    =&gt; 3,
		&#039;size&#039;       =&gt; &#039;thumbnail&#039;,
		&#039;exclude&#039;    =&gt; &#039;&#039; //  $id, &#039;post_status&#039; =&gt; &#039;inherit&#039;,
		&#039;post_type&#039; =&gt; &#039;attachment&#039;, &#039;post_mime_type&#039; =&gt; &#039;image&#039;, &#039;order&#039; =&gt; $order,
		&#039;orderby&#039; =&gt; $orderby, &#039;exclude&#039; =&gt; $exclude) );
		// the &#039;exclude&#039; portion at the end was added

	if ( empty($attachments) )
		return &#039;&#039;;
</pre>
<p>Now we have a function that pulls only the gallery images we want, excluding the ones we don&#8217;t want.  To use, switch your editor to HTML mode and insert the image you wish to exclude from the gallery (I apologize, but there is no other quick way that I know of to get the post id of the image besides inserting it into the post and reading from there, but I want to exclude images from the gallery because I&#8217;ve used them elsewhere in the post, so it wasn&#8217;t a big deal for me), in the image tag class attribute, you&#8217;ll see something like &#8220;wp-image-1822&#8243;, where the number is different for every image, this is the post id and that&#8217;s what you need to insert in your gallery shortcode to exclude as follows (remove the leading dot):</p>
<pre class="brush: text">
[.gallery exclude=&quot;1822,1845,1236&quot;]
</pre>
<p>And there you have it, images excluded from your gallery.</p>
<p>Here is my complete function and hook.  Note I also made some CSS changes to fit the gallery in with my floated right sidebar, which was breaking due to the floated gallery images and the clears that were on them.  You can use this as is, or edit to suit your needs.</p>
<pre class="brush: php">
/**
 * The Gallery shortcode.
 *
 * This alters the functionality of the Gallery Shortcode for displaying
 * WordPress images on a post.
 * This function also adds an aditional option to the gallery shortcode:
 *   exclude = excludes the list of post (image) ids from the gallery
 *
 * @since 2.5.0
 *
 * @param mixed $null space filler to take up empty string argument passed by WP
 * @param array $attr Attributes attributed to the shortcode.
 * @return string HTML content to display gallery.
 */
function my_gallery_shortcode($null, $attr = array( )) {
	global $post;

	// We&#039;re trusting author input, so let&#039;s at least make sure it looks like a valid orderby statement
	if ( isset( $attr[&#039;orderby&#039;] ) ) {
		$attr[&#039;orderby&#039;] = sanitize_sql_orderby( $attr[&#039;orderby&#039;] );
		if ( !$attr[&#039;orderby&#039;] )
			unset( $attr[&#039;orderby&#039;] );
	}

	extract(shortcode_atts(array(
		&#039;order&#039;      =&amp;gt; &#039;ASC&#039;,
		&#039;orderby&#039;    =&amp;gt; &#039;menu_order ID&#039;,
		&#039;id&#039;         =&amp;gt; $post-&amp;gt;ID,
		&#039;itemtag&#039;    =&amp;gt; &#039;dl&#039;,
		&#039;icontag&#039;    =&amp;gt; &#039;dt&#039;,
		&#039;captiontag&#039; =&amp;gt; &#039;dd&#039;,
		&#039;columns&#039;    =&amp;gt; 3,
		&#039;size&#039;       =&amp;gt; &#039;thumbnail&#039;,
		&#039;exclude&#039;    =&amp;gt; &#039;&#039;
	), $attr));

	$id = intval($id);
	$attachments = get_children( array(&#039;post_parent&#039; =&amp;gt; $id, &#039;post_status&#039; =&amp;gt; &#039;inherit&#039;,
	&#039;post_type&#039; =&amp;gt; &#039;attachment&#039;, &#039;post_mime_type&#039; =&amp;gt; &#039;image&#039;, &#039;order&#039; =&amp;gt; $order,
	&#039;orderby&#039; =&amp;gt; $orderby, &#039;exclude&#039; =&amp;gt; $exclude) );

	if ( empty($attachments) )
		return &#039;&#039;;

	if ( is_feed( ) ) {
		$output = &quot;\n&quot;;
		foreach ( $attachments as $id =&amp;gt; $attachment )
			$output .= wp_get_attachment_link($id, $size, true) . &quot;\n&quot;;
		return $output;
	}

	$itemtag = tag_escape($itemtag);
	$captiontag = tag_escape($captiontag);
	$columns = intval($columns);
	$itemwidth = $columns &amp;gt; 0 ? floor(100/$columns) : 100;

	$output = apply_filters(&#039;gallery_style&#039;, &quot;

	.gallery {
		margin: auto;
	}
	.gallery:after {
		content: &#039;.&#039;;
		display: block;
		height: 0;
		clear: left;
		visibility: hidden;
	}
	.gallery-item {
		float: left;
		margin-top: 10px;
		text-align: center;
		width: {$itemwidth}%;
	}
	.gallery-caption {
		margin-left: 0;
	}

	&lt;!-- see my_gallery_shortcode( ) in {theme_dir}/functions.php --&gt;
	&lt;div class=&#039;gallery&#039;&gt;&quot;);

	$i = 0;
	foreach ( $attachments as $id =&amp;gt; $attachment ) {
		$link = isset($attr[&#039;link&#039;]) &amp;amp;&amp;amp; &#039;file&#039; == $attr[&#039;link&#039;]
			? wp_get_attachment_link($id, $size, false, false)
			: wp_get_attachment_link($id, $size, true, false);

		$output .= &quot;&quot;;
		$output .= &quot;

		$link
		&quot;;
		if ( $captiontag &amp;amp;&amp;amp; trim($attachment-&amp;gt;post_excerpt) ) {
			$output .= &quot;

			{$attachment-&amp;gt;post_excerpt}
			&quot;;
		}
		$output .= &quot;&quot;;
	}

	$output .= &quot;
	&lt;/div&gt;\n&quot;;

	return $output;
}
add_filter(&#039;post_gallery&#039;, &#039;my_gallery_shortcode&#039;, 10, 2);
</pre>
<p>I hope this helps somebody, and please leave any questions or comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2009/05/filter-images-from-wordpress-gallery/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Dynamically inserting JavaScript and CSS with JavaScript</title>
		<link>http://dojo.codegreene.com/2009/03/dynamically-inserting-javascript-and-css-with-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dynamically-inserting-javascript-and-css-with-javascript</link>
		<comments>http://dojo.codegreene.com/2009/03/dynamically-inserting-javascript-and-css-with-javascript/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 00:06:43 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=208</guid>
		<description><![CDATA[Before we start this discussion, I&#8217;d like to point out that while dynamically inserting JavaScript and CSS can easily be done with PHP, or your server-side scripting language of choice, those solutions don&#8217;t apply to static HTML pages (what? static pages? what are those?), and I came across a situation where I needed a non-PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Before we start this discussion, I&#8217;d like to point out that while dynamically inserting JavaScript and CSS can easily be done with PHP, or your server-side scripting language of choice, those solutions don&#8217;t apply to static HTML pages (what? static pages? what are those?), and I came across a situation where I needed a non-PHP solution.</p>
<p>On my personal website, I have a single static page, my home page.  This page does nothing but provide links to the rest of my site, and as such, it does not need to be PHP driven with all the bells and whistles that go with it.  Just some clean code, and some clean CSS to make it pretty.  Recently I found a small JavaScript snippet that I wanted on my home page, so I added it, and it looked good.  The trouble is that it&#8217;s a seasonal script, and it makes no sense to leave it on all year.  So instead of editing my page twice a year to add and remove this script, I figured I could go one better and dynamically add the script to my page via JavaScript.  After a quick search I found <a href="http://www.codehouse.com/javascript/articles/external/">Dynamically Loading External JavaScript Files</a> which has a couple of methods listed to do this.  After looking them over, I decided the DHTML method would suit my needs better.</p>
<p>Here is that method:</p>
<pre class="brush: js">
function load_script(url) {
   var e = document.createElement(&quot;script&quot;);
   e.src = url;
   e.type = &quot;text/javascript&quot;;
   document.getElementsByTagName(&quot;head&quot;)[0].appendChild(e);
}
</pre>
<p><span id="more-208"></span></p>
<p>All this does is create a <tt>&lt;script&gt;</tt> tag, populate it with our data, and insert it into the head of the page.  This works beautifully, but only after some of the page has been loaded already.  And what better way to make sure that some of the page has been loaded than with the <tt>window.onload</tt> event?</p>
<pre class="brush: js">
window.onload = function( ) {
	var date = new Date;
	var month = date.getMonth( ) + 1; // +1 due to index 0

	// we only want this run between october and march
	if ((10 &lt;= month) || (3 &gt;= month)) {
		load_script(&quot;scripts/winter/seasonal_script.js&quot;);
	}
}
</pre>
<p>So now I have my seasonal script running only during the winter months.</p>
<p>But I&#8217;ve done something horrible, and you may have caught it&#8230;  I just killed any previously set <tt>window.onload</tt> function.  To remedy this, you can choose from a couple of different approaches:</p>
<ol>
<li>Use JavaScript&#8217;s <tt>addEventListener</tt> function to append your function to the <tt>window.onload</tt> event</li>
<li>Store any previous <tt>window.onload</tt> event in a variable and then re-insert it into the function</li>
</ol>
<p>I chose to use the latter for this because for some reason or another, I couldn&#8217;t get the <tt>addEventListener</tt> function to work properly.  Here is my modified code to reflect this change:</p>
<pre class="brush: js">
var prevLoad = window.onload; // store any previous window.onload event
window.onload = function( ) {
	// test and make sure it was a valid function, and if so, run it here
	if (&quot;function&quot; == typeof prevLoad) {
		prevLoad( );
	}

	var date = new Date;
	var month = date.getMonth( ) + 1; // +1 due to index 0

	// we only want this run between october and march
	if ((10 &lt;= month) || (3 &gt;= month)) {
		load_script(&quot;scripts/winter/seasonal_script.js&quot;);
	}
}
</pre>
<p>That solves that problem.</p>
<p>One other thing that this script needs, is it uses a CSS file to style some of the effects that it&#8217;s running, and that style sheet is in my <tt>&lt;head&gt;</tt> tag with the rest of my style sheets.  But I now only need it during the winter months, and the rest of the year, it&#8217;s just moldy bandwitch.</p>
<p>To remedy this, I took a look at the <tt>load_script</tt> function and it hit me&#8230;  it&#8217;s basically the same thing, a tag loaded in the head of the page.  So I modified the function:</p>
<pre class="brush: js">
function load_css(url) {
   var e = document.createElement(&quot;link&quot;);
   e.href = url;
   e.type = &quot;text/css&quot;;
   e.rel = &quot;stylesheet&quot;;
   e.media = &quot;screen&quot;;
   document.getElementsByTagName(&quot;head&quot;)[0].appendChild(e);
}
</pre>
<p>Now I have two functions that supplement each other quite nicely, and a snippet of code to place them in to make the whole shebang work and download the stuff I need, only when I need it.</p>
<p>Now we just add the new function into the script and we get the following:</p>
<pre class="brush: js">
var prevLoad = window.onload;
window.onload = function( ) {
	if (&quot;function&quot; == typeof prevLoad) {
		prevLoad( );
	}

	var date = new Date;
	var month = date.getMonth( ) + 1; // +1 due to index 0

	// we only want this run between october and march
	if ((10 &lt;= month) || (3 &gt;= month)) {
		load_css(&quot;scripts/winter/seasonal_style.css&quot;);
		load_script(&quot;scripts/winter/seasonal_script.js&quot;);
	}
}
</pre>
<p>And there you have it, dynamically loaded JavaScript and CSS and not a drop of PHP to be found.  The great part is, because this is all run only when we need it, it degrades gracefully as well (provided you&#8217;re not using it to load something required all the time).</p>
<p>A couple of gotcha&#8217;s I discovered while using this method:  I was trying to dynamically load a script that had some required HTML to go with it, and I thought, what better way to dynamically load HTML than with jQuery.  Well&#8230; it turns out that if you load jQuery with this method, you can&#8217;t actually use jQuery from within the <tt>window.onload</tt> function itself, you need to pull in another JavaScript file and use it there.  I&#8217;m not exactly sure why, but my hunch is that it doesn&#8217;t load up jQuery until after the <tt>window.onload</tt> function is done running, and by that time, it&#8217;s too late.  My solution was the following:</p>
<pre class="brush: js">
var prevLoad = window.onload;
window.onload = function( ) {
	if (&quot;function&quot; == typeof prevLoad) {
		prevLoad( );
	}

	load_css(&quot;scripts/style.css&quot;);
	load_script(&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js&quot;);
	load_script(&quot;scripts/build_html.js&quot;);
	load_script(&quot;scripts/run_script.js&quot;);
}
</pre>
<p>This way, the CSS is loaded and ready for the script, then we pull in jQuery, build our required HTML, and then run the script.  Nothing gets left out, and we can run any kind of logic before hand to determine if we want to run this script or not.  And if not, there is nothing left behind in our code to take up bandwidth, or otherwise make it ugly. </p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2009/03/dynamically-inserting-javascript-and-css-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cssWithVars: jQuery plugin review</title>
		<link>http://dojo.codegreene.com/2009/03/csswithvars-jquery-plugin-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=csswithvars-jquery-plugin-review</link>
		<comments>http://dojo.codegreene.com/2009/03/csswithvars-jquery-plugin-review/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 21:21:36 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=194</guid>
		<description><![CDATA[A colleague of mine (Tim) introduced me to a jQuery plugin that I had not heard of before. The plugin is called cssWithVars. This plugin makes use of some JavaScript and jQuery magic to bring variables and reuse to the CSS world. I recently looked through the example given with the download, played around with [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine (Tim) introduced me to a <a href="http://jquery.com/">jQuery</a> plugin that I had not heard of before.  The plugin is called <a href="http://plugins.jquery.com/project/cssWithVars">cssWithVars</a>.  This plugin makes use of some JavaScript and jQuery magic to bring variables and reuse to the <acronym title="Cascading Style Sheet">CSS</acronym> world. I recently looked through the example given with the download, played around with it, took a look at the backend magic, and here is what I thought about it.</p>
<p>While the background magic is actually pretty simple (look for any properties using a variable, which are wrapped in <tt>[ ]</tt>, and if found, look for the related selector, and insert the properties defined in that selector into the variable instance), the implications are great.  What this means is that you can create various pieces of style that can be reused anywhere and when it comes time to edit those styles, you simply edit the one instance and they all work.  Here is an example style sheet:</p>
<pre class="brush: css">
text_box { /* this becomes a variable */
	width: 100px;
	height: 100px;
}

notice { /* this becomes a variable */
	color: #F00;
	font-weight: bold;
}

p {
	[text_box] /* a variable in use */
}

h2 {
	[notice] /* another variable in use */
}

h3 {
	[h2] /* normal selectors can be variables as well */
	font-size: smaller;
}

p.alert {
	[text_box]
	[notice]
	/* normal properties can be used as well */
	border: 2px solid #000;
}
</pre>
<p>As you can surmise, changing the details of the <var>[notice]</var> variable (or any of the other variables) would be extremely easy.  Simply change the color, or font-weight, in the selector where it gets defined and it propagates through to all the other instances.  This, to me, is what got me intrigued by this plugin.  It has far reaching implications, and can be a very powerful thing.  But as with all great power comes great responsibility (and confusion.)  With this, it becomes increasingly difficult to say what properties are applied to what selector, or even where they come from.  Say for instance I have a variable that sets a border style and I use it in a property that also sets a border style, which one gets used?  I would imagine the one that is set explicitly in that selector gets used, but then what if I am using two variable styles that both try to apply conflicting styles, one floated left, and the other floated right&#8230;  what then?  Which one is the intended style?</p>
<p>This could get ugly.</p>
<p>One more thing that you may or may not have thought of&#8230; What if JavaScript is turned <strong>off</strong>?</p>
<p>This little question is a deal breaker for me on this plugin.  Not only is it a deal breaker, but it completely turns the tables on my recommendation of this plugin.  Not only is the CSS completely invalid, but in the (not so) rare case that the user has JavaScript turned off, they are going to see, in the best case scenario, a completely unstyled page, and in the worst case scenario, a page that looks like it was rendered with IE (yes, that&#8217;s bad.)</p>
<p>It is for this reason that I recommend that, while this plugin has it&#8217;s intriguing ideas, and is certainly fun to play with, should not be used in a production environment, because it has a poor execution (through no fault of the developer, but due to the possibility of broken pages due to invalid CSS and disabled JavaScript.)  But CSS spec writers take notice, this would be a great and powerful addition to CSS.  But it would take a lot of thought to get some of the caveats I&#8217;ve mentioned here (and more that I didn&#8217;t) working together as the designer intended.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2009/03/csswithvars-jquery-plugin-review/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Why we use CakePHP</title>
		<link>http://dojo.codegreene.com/2009/02/why-we-use-cakephp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-we-use-cakephp</link>
		<comments>http://dojo.codegreene.com/2009/02/why-we-use-cakephp/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 17:46:41 +0000</pubDate>
		<dc:creator>Benjam</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://dojo.codegreene.com/?p=148</guid>
		<description><![CDATA[When I first started working at Code Greene, I was building my PHP applications and sites the &#8220;old fashioned&#8221; way, with nothing more than a collection of common functions and a single MySQL class that I carried around with me everywhere. I have grown very accustomed to my small collection of code, and have begun [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cakephp.org/"><img src="http://dojo.codegreene.com/wp-content/uploads/2009/02/cake-logo.png" alt="Cake Logo" width="180" height="180" class="alignright size-full wp-image-159" /></a>When I first started working at Code Greene, I was building my PHP applications and sites the &#8220;old fashioned&#8221; way, with nothing more than a collection of common functions and a single MySQL class that I carried around with me everywhere. I have grown very accustomed to my small collection of code, and have begun to rely on it a bit (and actually almost failed the entrance test to Code Greene because I couldn&#8217;t find it).  But I always built my applications from scratch, every time. </p>
<p>As I progressed in my PHP career (and hobbies), I noticed that I was building the same things over and over again, but only slightly different every time.  This was an issue that I had noticed but never really put some serious thought into&#8230; until I started at Code Greene.  My first day there, I was told to take a look at CakePHP and learn it, because it was to be the defacto PHP framework for the office.  I took a quick glance at the code base and was instantly overwhelmed.  There is so much stuff going on behind the scenes in Cake that it boggles the mind a bit.  I went through a few online tutorials, and still felt that I knew nothing about it, let alone how to use it, but I could tell that it would either make or break my new job.<br />
<span id="more-148"></span></p>
<p>My first Cake project with CG was not an easy one&#8211;it was huge.  It was the largest project I had worked on to date, and to top it off, I was forced to code it in Cake, which is almost a whole new language in itself.  As I worked on the project, I felt very frustrated at times, and wanted to just slip outside of the Cake bubble and code things the way I knew how, with some straight PHP.  But I didn&#8217;t, and I&#8217;m glad.  I&#8217;m sure I made a ton of rookie mistakes.  There is an extremely steep learning curve, but I was progressing with my Cake experience, and it&#8217;s well worth it once you get the hang of it.</p>
<p>As I work on projects now, I can pretty much get the whole back-end of the site, and all the inner workings and relationships between the data in the database and everything the administrator needs to <acronym title="Create Read Update Delete">CRUD</acronym> that data set up in less than a day, even for fairly large projects.  All the magic in the background is provided by Cake.  All I have to do is give it some details and let it do it&#8217;s thing.  It truly is cake.  Today, I can turn a small project around in a day or two, when it used to take me a week just to get the relationships and administration stuff built, not including the front end portion of the site.</p>
<p>I&#8217;m by no means a Cake expert, but I have cut my build times down to less than half, and in some cases you can count the percentage decrease on two hands.  I am also no longer overwhelmed by requests for gigantic monolithic sites, and requests to change things that would normally make me cringe.  I look at some of the sites that we build at the office, and I wonder how we could ever possibly build these sites in the time that we do if we didn&#8217;t use Cake. It&#8217;s a win-win situation for both the office and our clients. We don&#8217;t have to sweat the little things, and the client gets a fully-functional site in much less time.</p>
<p>My opinion of Cake may be a bit biased, as I have no basis for comparison.  Other frameworks may be better suited for some of our smaller sites that we build, but I have no doubt that for our larger sites, Cake is the right choice.  In the future, I would also love to try some other frameworks, if only to compare them with Cake, but I&#8217;m pretty sure that CakePHP will always be my framework of choice.</p>
<p>What&#8217;s your framework of choice?  Leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://dojo.codegreene.com/2009/02/why-we-use-cakephp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

