<?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>Codeistry blog &#187; snippet</title>
	<atom:link href="http://www.codeistry.com/blog/tag/snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codeistry.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 14 Aug 2009 08:10:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MODx Snippet: New version of Wayfinder</title>
		<link>http://www.codeistry.com/blog/2009/01/modx-snippet-new-version-of-wayfinder/</link>
		<comments>http://www.codeistry.com/blog/2009/01/modx-snippet-new-version-of-wayfinder/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 00:21:51 +0000</pubDate>
		<dc:creator>Duncan Lock</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[modx]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[wayfinder]]></category>

		<guid isPermaLink="false">http://www.codeistry.com/blog/?p=215</guid>
		<description><![CDATA[Good news everyone! During my development travails, I&#8217;ve created an updated version of Wayfinder that fixes two issues and adds two handy new features! Fixes I&#8217;ve incorporated this fix which makes the hereClass work properly with weblinks in the menu and I&#8217;ve fixed the SQL query to work around the MySQL 5.0.51 sorting bug. New [...]]]></description>
			<content:encoded><![CDATA[<p>Good news everyone! During my development travails, I&#8217;ve created an updated version of Wayfinder that <strong>fixes two issues</strong> and <strong>adds two handy new features</strong>!</p>
<h3>Fixes</h3>
<p>I&#8217;ve incorporated <a href="http://modxcms.com/forums/index.php/topic,28461.0.html">this fix</a> which makes the hereClass work properly with weblinks in the menu and I&#8217;ve fixed the SQL query to work around the MySQL 5.0.51 sorting bug.</p>
<h3>New Features</h3>
<h4>lastRowTpl</h4>
<p>I&#8217;ve also added a new parameter called <strong>lastRowTpl</strong> which allows you specify a chunk to be used for the last menu item output. It works the same way as all the other wayfinder tpl&#8217;s and defaults to using rowTpl is it isn&#8217;t specified.</p>
<p>It&#8217;s very useful for little menu&#8217;s that currently look like this if you do them with Wayfinder:</p>
<pre>item1 | item2 | item3 | lastitem |</pre>
<p>and should look like this:</p>
<pre>item1 | item2 | item3 | lastitem</pre>
<h4>Odd &amp; Even classes</h4>
<p>Finally, I&#8217;ve added support for even &amp; odd classes on rows. These work like all the other wayfinder classes &#8211; you specify a class name in the parameter and this will be added to the wf.classes placeholder. These ones are only output on the appropriate rows, though &#8211; and you don&#8217;t have to specify both if you don&#8217;t want to &#8211; it&#8217;ll still work with just one.</p>
<p>These are really useful for menu&#8217;s which are supposed to be stripey, with every other item a different colour.</p>
<p>To implement this, I&#8217;ve modified both Wayfinder files. You can download the new versions from <a href="http://www.codeistry.com/assets/files/wayfinder-201.zip">here (.zip)</a> or <a href="http://www.codeistry.com/assets/files/wayfinder-201.tar.gz">here (.tar.gz)</a>.</p>
<p>I&#8217;m using these on live sites, because I&#8217;m a crazy fool, but if we can get some more testing from everyone, maybe this can be added to the repository as a new version and maybe then into the main MODx distribution, so that everyone can share the love.</p>
<p>What do you think &#8211; <a href="http://modxcms.com/forums/index.php/topic,31895.0.html">let me know in the MODx forum thread</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codeistry.com/blog/2009/01/modx-snippet-new-version-of-wayfinder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MODx Snippet: ChunkIf</title>
		<link>http://www.codeistry.com/blog/2008/11/modx-snippet-chunkif/</link>
		<comments>http://www.codeistry.com/blog/2008/11/modx-snippet-chunkif/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 14:16:59 +0000</pubDate>
		<dc:creator>Duncan Lock</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[modx]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.codeistry.com/blog/?p=65</guid>
		<description><![CDATA[Ages ago, I wrote a MODx snippet called ChunkIf and I thought it was about time that I shared it with the MODx community. ChunkIf allows you to choose which of two chunks gets output, based on a template variable being set or not; its not big or clever but I find it useful and [...]]]></description>
			<content:encoded><![CDATA[<p>Ages ago, I wrote a MODx snippet called ChunkIf and I thought it was about time that I shared it with the MODx community. ChunkIf allows you to choose which of two chunks gets output, based on a template variable being set or not; its not big or clever but I find it useful and hopefully you might do, too.</p>
<p>The long form of the snippet call looks like this:</p>
<pre>[[ChunkIf? &amp;tv=`tvname` &amp;trueChunk=`chunkname` &amp;falseChunk=`chunkname`  &amp;debug=`1|0` ]]</pre>
<p>The parameters to the snippet call work like this:</p>
<dl>
<dt>&amp;tv</dt>
<dd>This is the name of the template variable you want to test. The value of this variable will be checked and if it&#8217;s not empty or blank, &amp;trueChunk will be output &#8211; otherwise &amp;falseChunk will be.</dd>
<dt>&amp;trueChunk</dt>
<dd>The name of the chunk who&#8217;s content you want output, in the event that your template variable (&amp;tv) has a value.</dd>
<dt>&amp;falseChunk</dt>
<dd>The name of the chunk who&#8217;s content you want output, if your template variable (&amp;tv) is empty. If you omit this parameter, an empty string will be output if &amp;tv is empty.</dd>
<dt>&amp;debug</dt>
<dd>Set this to 1 to emit debugging comments into the HTML output; set it to 0 or leave it out to switch off.</dd>
</dl>
<p>There is a short version too:</p>
<pre>[[ChunkIf? &amp;tv=`tvname` ]]</pre>
<p>The shorthand form attempts to output the contents of a chunk with the same name as &amp;tv, if &amp;tv is set, or an empty string. If there&#8217;s no chunk with the same name, it also returns an empty string.</p>
<p>This shorthand version is very handy for switching chunks on and off using a single variable. As chunks can contain other chunks and snippet calls, you can use this to switch sidebars, footers and other complex bits of layout on and off on a per page basis, with a simple checkbox template variable.</p>
<pre class="brush: php; ">

&lt;?php
	/*
		Version: 0.2
		Date: 21/07/2008
		Description:
			&lt;strong&gt;0.2&lt;/strong&gt; Outputs the contents of the chunk passed in
			$trueChunk if the template variable passed in $tv is set (i.e. has a value).
			Otherwise outputs the contents of the $falseChunk chunk. Expects $tv to be the
			name of the Template Variable to test, and $trueChunk &amp; $falseChunk to be names
			of chunks.

		eg:

		[[ChunkIf? &amp;tv=`tvname` &amp;trueChunk=`chunkname` &amp;falseChunk=`chunkname` ]]
			- Long version outputs $trueChunk if $tv has a value, otherwise
			outputs $falseChunk.
		[[ChunkIf? &amp;tv=`tvname` &amp;trueChunk=`chunkname` ]]
			- This short version outputs an empty string if $tv has no value.
		[[ChunkIf? &amp;tv=`tvname` ]]
			- This very short version attempts to output the contents of a chunk
			 with the same name as $tv
		[[ChunkIf? &amp;tv=`tvname` &amp;debug=`1` ]]
			- Switches on debugging output - output&#039;s HTML comments for debugging.

	*/

	// get tv name
	$tv = isset( $tv ) ? $tv : &#039;&#039;;

	// get current page ID
	$id = isset( $id )? $id: $modx -&gt; documentObject[&#039;id&#039;];

	// Get the value of $tv
	$tvarray = $modx -&gt; getTemplateVarOutput( $tv, $id );
	$value = &#039;&#039;.trim($tvarray[$tv]);

	if ($debug) {
		$dtmp = &#039;&lt;!--&#039;;
		$dtmp .= &#039;tv: &#039;.$tv.&#039;, &#039;;
		$dtmp .=  &#039;id: &#039;.$id.&#039;, &#039;;
		$dtmp .=  &#039;value: &#039;.$value;
		$dtmp .=  &#039;--&gt;&#039;;

		echo $dtmp;
	}

	// Decide which chunk to return.
	if ($value == &#039;&#039;) {
		// get chunk to return if $tv has no value
		$falseChunk = isset( $falseChunk )? $modx -&gt; getChunk( $falseChunk ): &#039;&#039;;
		return $falseChunk;
	} else {
		// get chunk to return if $tv has a value
		if (isset( $trueChunk ))
		{
			$trueChunk = $modx -&gt; getChunk( $trueChunk );
		} else {
			// Attempt to get the chunk with the same name as $tv
			$trueChunk = $modx -&gt; getChunk( $tv );
		}
		return $trueChunk;
	}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.codeistry.com/blog/2008/11/modx-snippet-chunkif/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
