<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>Train&#45;ee.com Free Tutorials</title>
    <link>http://www.train-ee.com/courseware/free-tutorials/</link>
    <description>Learn ExpressionEngine Fast with Free Tutorials from Train-ee.com</description>
    <dc:language>en</dc:language>
    <dc:creator>eeforme@train-ee.com</dc:creator>
    <dc:rights>Copyright 2012</dc:rights>
    <dc:date>2012-02-10T19:34:49+00:00</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />
    

    <item>
      <title>Working with ExpressionEngine Categories</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/working-with-categories/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/working-with-categories/#When:19:34:49Z</guid>
	<description>
		<![CDATA[
			<p>It&#8217;s funny how certain topics come up at different times in the <a href="http://www.expressionengine.com/index.php?affiliate=boyink">ExpressionEngine</a> world. Over the past couple of weeks I&#8217;ve noted many forum threads around EE&#8217;s categories so it seemed time to write a tutorial around them.
</p> <p>No one seems to get confused over setting up category groups, creating categories and assigning entries to them so I won&#8217;t cover that here (sales pitch - that process does get covered in step by step detail in <a href="http://www.train-ee.com/courseware/books/detail/building-an-expressionengine-2-site-small-business/">my book</a>).</p>

<p>The confusion seems to come from how to create a reusable template to display categorized results. The channel:entries tag has a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fchannel_entries.html%23category">category parameter</a> that I think misleads people into thinking they somehow need to force-feed the entries tag with the ID of the category they wish to display, and if that&#8217;s the case then can you dynamically set that ID or do you have to create different templates with the ID hardcoded?</p>

<p>This isn&#8217;t the case - we&#8217;re actually looking at a situation where the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fchannel_entries.html%23dynamic">dynamic property</a> of ExpressionEngine is valuable.&nbsp; If you haven&#8217;t yet, I would suggest a quick view of the <a href="http://www.train-ee.com/courseware/free-tutorials/comments/dynamic-off-explained/">dynamic=&#8220;off&#8221; explained screencast</a> here on Train-ee.&nbsp; While the parameter values have changed (EE1 was Off/On, EE2 is Yes/No) the functionality is the same. The screencast focuses on single-entry views but the channel:entries tag dynamically responds in a few different situations - reading single entry URLs, pagination URLs, archival URLs and - what we&#8217;re interested in today - category URLs.</p>

<p><strong>How to Create a Reusable Category Template</strong><br />
Here&#8217;s a quick screencast that shows a simple EE template and how it responds when fed proper category URLs:</p>

<p> </p><object id="scPlayer"  width="476" height="377" type="application/x-shockwave-flash" data="http://content.screencast.com/users/train-ee/folders/Jing/media/730e9325-9c7d-468a-aab4-03831aa48c12/jingswfplayer.swf" > <param name="movie" value="http://content.screencast.com/users/train-ee/folders/Jing/media/730e9325-9c7d-468a-aab4-03831aa48c12/jingswfplayer.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <param name="flashVars" value="thumb=http://content.screencast.com/users/train-ee/folders/Jing/media/730e9325-9c7d-468a-aab4-03831aa48c12/FirstFrame.jpg&amp;containerwidth=731&amp;containerheight=579&amp;content=http://content.screencast.com/users/train-ee/folders/Jing/media/730e9325-9c7d-468a-aab4-03831aa48c12/00000006.swf&amp;blurover=false" /> <param name="allowFullScreen" value="true" /> <param name="scale" value="showall" /> <param name="allowScriptAccess" value="always" /> <param name="base" value="http://content.screencast.com/users/train-ee/folders/Jing/media/730e9325-9c7d-468a-aab4-03831aa48c12/" /> Cool screencast here - but you need Flash!</object>
<p>&nbsp;</p><p>
<strong>How to Create Category Links</strong><br />
Another short screencast shows how to dynamically create category links that feed the template the category URLs that it needs to be reusable:</p>

<!-- copy and paste. Modify height and width if desired. --><object id="scPlayer"  width="476" height="346" type="application/x-shockwave-flash" data="http://content.screencast.com/users/train-ee/folders/Jing/media/78f2b03a-20aa-4b7d-a542-cd862c9f4f78/jingswfplayer.swf" > <param name="movie" value="http://content.screencast.com/users/train-ee/folders/Jing/media/78f2b03a-20aa-4b7d-a542-cd862c9f4f78/jingswfplayer.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <param name="flashVars" value="thumb=http://content.screencast.com/users/train-ee/folders/Jing/media/78f2b03a-20aa-4b7d-a542-cd862c9f4f78/FirstFrame.jpg&amp;containerwidth=685&amp;containerheight=498&amp;content=http://content.screencast.com/users/train-ee/folders/Jing/media/78f2b03a-20aa-4b7d-a542-cd862c9f4f78/00000007.swf&amp;blurover=false" /> <param name="allowFullScreen" value="true" /> <param name="scale" value="showall" /> <param name="allowScriptAccess" value="always" /> <param name="base" value="http://content.screencast.com/users/train-ee/folders/Jing/media/78f2b03a-20aa-4b7d-a542-cd862c9f4f78/" /> Cool Screencast here - but you again need Flash!</object>
<p>&nbsp;</p><p>
Note: I didn&#8217;t code that second link correctly.&nbsp; It should be:
</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">a&nbsp;href</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;path='cat_demo/index'&#125;"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Cat&nbsp;Demo</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p><strong>How To Show Which Categories a Single Entry is Assigned To</strong><br />
This question comes up a bit - and the answer is the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fchannel_entries.html%23categories">{categories}{/categories}</a> variable pair for the channel:entries tag.&nbsp; This is a &#8220;looping variable pair&#8221; meaning for every one entry in a channel, it will loop once for every category that entry is assigned to.&nbsp; This is what allows a given entry to be assigned to multiple entries and have each of those category names get displayed for the entry.</p>

<p>In our little demo code it would be used this way:
</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Entries</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"releases"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;&nbsp;posted&nbsp;in&nbsp;&#123;categories&#125;&#123;category_name&#125;&nbsp;&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">categories&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>If you wanted those to be links use the same {path= linking variable I showed in the screencast - again, because you're using it in a category context, it will return category links.</p>

<p><strong>How to Display Category Hierarchy</strong><br />
ExpressionEngine lets you create a hierarchy in your category group, nesting categories and subcategories as many layers deep as you wish.  The important thing to note here is that the hierarchy you create is <em>for display only, not for URLs</em>.  In other words, the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fcategories.html">channel:categories</a> tag I used in the screencast will return a nested list showing your hierarchy; but EE will not create URLs that display in a parent_category/sub_category fashion. Using native code, EE works with one category at a time in the URL and they will all display in the same /category/category_url_title fashion. </p>

<p><strong>How To Show Category and Entry URL Titles in the same URL</strong><br />
So I&#8217;ve clicked the &#8220;salsa&#8221; category, got my list of results, and then click on an entry in that list like &#8220;Harrison’s Hot Trotters&#8221;.&nbsp; Now I want to see a detail page for that entry that has a URL like: /cat_demo/salsa/harrisons-hot-trotters.&nbsp; How do I do that?</p>

<p>The short answer is, you don&#8217;t.&nbsp; At least not with native code.&nbsp; EE just isn&#8217;t designed to work with URLs in this way.&nbsp; Categories were designed to be a simple filter used to whittle down a long list of entries to something more manageable.&nbsp; Once you chose an entry from that list your URL is going to lose the category information.&nbsp; One reason for this is that ability to assign an entry into multiple categories - if the category stayed in the URL you could end up with the same single entry showing at multiple URLs.</p>

<p>I don&#8217;t believe EE categories were ever designed to be used as a navigation-building tool.&nbsp; EE has a blogging heritage and its category functionality grew out of that - giving users the ability to filter a large set of blog entries down to just entries in designated categories.</p>

<p><strong>You Keep Mentioning Native Code&#8230;</strong><br />
As usual with ExpressionEngine any time the native abilities come up short the 3rd party market rushes to fill that void.&nbsp; There are a number of category-related add-ons available and in future posts I&#8217;ll look at a couple of them that can ease some of your category pain.
</p>
		]]>
	</description>       

      <dc:subject>Quick n Dirty Screencasts</dc:subject>
      <dc:date>2012-02-10T19:34:49+00:00</dc:date>
    </item>

    <item>
      <title>Product Comparison Tool</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/product-comparison-tool/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/product-comparison-tool/#When:12:56:30Z</guid>
	<description>
		<![CDATA[
			<p>Client: &#8220;Now that we have all of our product data loaded into the new site, I want a tool where users can select multiple products and compare them side by side.&#8221;</p>

<p>Gulp&#8230;.&#8220;Let me think about that one for a bit&#8230;&#8221;
</p> <p>Not an unreasonable request, right?&nbsp; As a consumer I&#8217;ve often used such tools to quickly compare multiple products I was interested in purchasing.&nbsp; Comparison tables can quickly help you find differences and similarities that would be tough to see bouncing around different product-specific pages.</p>

<p>But how to pull this off on an <a href="http://www.expressionengine.com/index.php?affiliate=boyink">ExpressionEngine</a> based site?</p>

<p>As is so often the case with EE, what looks difficult at first blush turns out to not be too difficult.&nbsp; Let me show you the front end of what I came up with so you can better tell if it&#8217;s close to what you need:</p>

<p> </p><object id="scPlayer"  width="476" height="365" type="application/x-shockwave-flash" data="http://content.screencast.com/users/train-ee/folders/Jing/media/fe8d4800-7eca-455e-a0bb-126d1d519ffc/jingswfplayer.swf" > <param name="movie" value="http://content.screencast.com/users/train-ee/folders/Jing/media/fe8d4800-7eca-455e-a0bb-126d1d519ffc/jingswfplayer.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <param name="flashVars" value="thumb=http://content.screencast.com/users/train-ee/folders/Jing/media/fe8d4800-7eca-455e-a0bb-126d1d519ffc/FirstFrame.jpg&amp;containerwidth=762&amp;containerheight=569&amp;content=http://content.screencast.com/users/train-ee/folders/Jing/media/fe8d4800-7eca-455e-a0bb-126d1d519ffc/00000005.swf&amp;blurover=false" /> <param name="allowFullScreen" value="true" /> <param name="scale" value="showall" /> <param name="allowScriptAccess" value="always" /> <param name="base" value="http://content.screencast.com/users/train-ee/folders/Jing/media/fe8d4800-7eca-455e-a0bb-126d1d519ffc/" /> There is a short screencast here that requires Flash, but isn&#8217;t crucial to the tutorial.</object>
<p>&nbsp;</p><p>
<strong>Overview</strong></p><ul><li>The drop-downs are dynamically populated from channel:entries tags so if our client adds or deletes products he won&#8217;t have to worry about replicating those edits for the drop-downs.</li>
<li>While the drop-downs display entry titles, you are really choosing entry_ids.</li>
<li>When you click &#8220;Compare&#8221; a bit of javascript grabs the entry_id&#8217;s from the 3 drop-downs, appends them onto the URL and reloads the template.</li>
<li>Additional channel:entries loops then see those entry_id&#8217;s and use them to retrieve the content for the chosen entry.</li>
<li>Each column is actually its own HTML table, floated using CSS to create the side-by-side view.</li>
</ul>

<p><strong>Main releases/compare Template</strong><br />
Let&#8217;s work through the main template (available as a download):</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;!</span><span style="color: #0000BB">doctype&nbsp;html</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">html</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">head</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">title</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Compare&nbsp;Releases</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">title</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">meta&nbsp;http</span><span style="color: #007700">-</span><span style="color: #0000BB">equiv</span><span style="color: #007700">=</span><span style="color: #DD0000">"content-type"&nbsp;</span><span style="color: #0000BB">content</span><span style="color: #007700">=</span><span style="color: #DD0000">"text/html;&nbsp;charset=utf-8"&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">script&nbsp;type</span><span style="color: #007700">=</span><span style="color: #DD0000">"text/javascript"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;</span><span style="color: #0000BB">Begin<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;site&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"http://localhost:8888/index.php/releases/compare/"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">combineMenus</span><span style="color: #007700">(</span><span style="color: #0000BB">frm</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">product_1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">product_2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">product_3</span><span style="color: #007700">)&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">frm</span><span style="color: #007700">)&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">product_1</span><span style="color: #007700">.</span><span style="color: #0000BB">options&#91;product_1</span><span style="color: #007700">.</span><span style="color: #0000BB">selectedIndex&#93;</span><span style="color: #007700">.</span><span style="color: #0000BB">value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">+=&nbsp;</span><span style="color: #0000BB">product_2</span><span style="color: #007700">.</span><span style="color: #0000BB">options&#91;product_2</span><span style="color: #007700">.</span><span style="color: #0000BB">selectedIndex&#93;</span><span style="color: #007700">.</span><span style="color: #0000BB">value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">+=&nbsp;</span><span style="color: #0000BB">product_3</span><span style="color: #007700">.</span><span style="color: #0000BB">options&#91;product_3</span><span style="color: #007700">.</span><span style="color: #0000BB">selectedIndex&#93;</span><span style="color: #007700">.</span><span style="color: #0000BB">value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">site&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">window</span><span style="color: #007700">.</span><span style="color: #0000BB">location</span><span style="color: #007700">.</span><span style="color: #0000BB">href&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">url</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;&nbsp;End&nbsp;--&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&lt;/script&gt;&nbsp;</span>
</span>
</code></div>

<p>This is the javascript that assembles the expected page URL including the 3 entry_id&#8217;s from the selected products.&nbsp; If you use this code make sure to change the site= parameter to the URL to your comparison template.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">style&nbsp;type</span><span style="color: #007700">=</span><span style="color: #DD0000">"text/css"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">table</span><span style="color: #007700">.</span><span style="color: #0000BB">compare&nbsp;&#123;width</span><span style="color: #007700">:</span><span style="color: #0000BB">170px</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">left</span><span style="color: #007700">;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;td&nbsp;&#123;text</span><span style="color: #007700">-</span><span style="color: #0000BB">align</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">left</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">padding</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">2px</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">height</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">28px</span><span style="color: #007700">;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;td</span><span style="color: #007700">.</span><span style="color: #0000BB">label&nbsp;&#123;text</span><span style="color: #007700">-</span><span style="color: #0000BB">align</span><span style="color: #007700">:</span><span style="color: #0000BB">right</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">padding</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">5px&nbsp;4px&nbsp;0px&nbsp;0px</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;th&nbsp;&#123;height</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">80px</span><span style="color: #007700">;</span><span style="color: #0000BB">&#125;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;form</span><span style="color: #FF8000">#compare_form&nbsp;&#123;padding:&nbsp;0px&nbsp;0px&nbsp;0px&nbsp;100px;&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">select&nbsp;&#123;width</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">167px</span><span style="color: #007700">;</span><span style="color: #0000BB">&#125;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">style</span><span style="color: #007700">&gt;<br />&lt;/</span><span style="color: #0000BB">head</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>Just some basic CSS mainly to get the result tables to line up by floating.&nbsp; I went this route because it made exception-handling much easier (what if user selects an option only from the first and third boxes, etc).&nbsp; </p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">body</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Compare&nbsp;Record&nbsp;Releases</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&lt;</span><span style="color: #0000BB">form&nbsp;name</span><span style="color: #007700">=</span><span style="color: #DD0000">"compare_releases"&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">=</span><span style="color: #DD0000">"compare_form"&nbsp;</span><span style="color: #0000BB">method</span><span style="color: #007700">=</span><span style="color: #DD0000">"post"&nbsp;</span><span style="color: #0000BB">action</span><span style="color: #007700">=</span><span style="color: #DD0000">"http://localhost:8888/index.php/releases/compare/"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">input&nbsp;type</span><span style="color: #007700">=</span><span style="color: #DD0000">"button"&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"compare_form"&nbsp;</span><span style="color: #0000BB">value</span><span style="color: #007700">=</span><span style="color: #DD0000">"Compare"&nbsp;</span><span style="color: #0000BB">onclick</span><span style="color: #007700">=</span><span style="color: #DD0000">"combineMenus(this.form,&nbsp;this.form.product_1,&nbsp;this.form.product_2,&nbsp;this.form.product_3)"&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">select&nbsp;name</span><span style="color: #007700">=</span><span style="color: #DD0000">"product_1"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">option&nbsp;value</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Choose&nbsp;Release</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">option</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"releases""&nbsp;dynamic="</span><span style="color: #0000BB">no</span><span style="color: #DD0000">"&nbsp;disable="</span><span style="color: #0000BB">trackbacks</span><span style="color: #007700">|</span><span style="color: #0000BB">categories</span><span style="color: #007700">|</span><span style="color: #0000BB">member_data</span><span style="color: #007700">|</span><span style="color: #0000BB">pagination</span><span style="color: #007700">|</span><span style="color: #0000BB">custom_fields</span><span style="color: #DD0000">"&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;value&nbsp;="</span><span style="color: #0000BB">&#123;entry_id&#125;</span><span style="color: #007700">/</span><span style="color: #DD0000">"&nbsp;&#123;if&nbsp;segment_3==entry_id&#125;selected="</span><span style="color: #0000BB">selected</span><span style="color: #DD0000">"&#123;/if&#125;&nbsp;&gt;&#123;title&#125;&lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;/exp:channel:entries&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;select&nbsp;name="</span><span style="color: #0000BB">product_2</span><span style="color: #DD0000">"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;value=""&gt;Choose&nbsp;Release&lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;exp:channel:entries&nbsp;channel="</span><span style="color: #0000BB">releases</span><span style="color: #DD0000">""&nbsp;</span><span style="color: #0000BB">dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"trackbacks|categories|member_data|pagination|custom_fields"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">option&nbsp;value&nbsp;</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;entry_id&#125;/"&nbsp;</span><span style="color: #0000BB">&#123;if&nbsp;segment_4</span><span style="color: #007700">==</span><span style="color: #0000BB">entry_id&#125;selected</span><span style="color: #007700">=</span><span style="color: #DD0000">"selected"</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">option</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">select</span><span style="color: #007700">&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">select&nbsp;name</span><span style="color: #007700">=</span><span style="color: #DD0000">"product_3"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">option&nbsp;value</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Choose&nbsp;Release</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">option</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"releases""&nbsp;dynamic="</span><span style="color: #0000BB">no</span><span style="color: #DD0000">"&nbsp;disable="</span><span style="color: #0000BB">trackbacks</span><span style="color: #007700">|</span><span style="color: #0000BB">categories</span><span style="color: #007700">|</span><span style="color: #0000BB">member_data</span><span style="color: #007700">|</span><span style="color: #0000BB">pagination</span><span style="color: #007700">|</span><span style="color: #0000BB">custom_fields</span><span style="color: #DD0000">"&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option&nbsp;value&nbsp;="</span><span style="color: #0000BB">&#123;entry_id&#125;</span><span style="color: #007700">/</span><span style="color: #DD0000">"&nbsp;&#123;if&nbsp;segment_5==entry_id&#125;selected="</span><span style="color: #0000BB">selected</span><span style="color: #DD0000">"&#123;/if&#125;&nbsp;&gt;&#123;title&#125;&lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;/exp:channel:entries&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br />&lt;/form&gt;&nbsp;</span>
</span>
</code></div>

<p>These are the dynamically-generated drop-downs.&nbsp; It may or may not make sense to chunk these out into a reusable embedded template or snippet, but since they are pretty simple I just left them this way. All we need are the default fields from the channel so our <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fchannel_entries.html%23disable">disable parameter</a> can disable everything else for best performance.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&#123;if&nbsp;segment_3&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""&nbsp;</span><span style="color: #007700">OR&nbsp;</span><span style="color: #0000BB">segment_4&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""&nbsp;</span><span style="color: #007700">OR&nbsp;</span><span style="color: #0000BB">segment_5&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">table&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"compare"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">thead</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">th</span><span style="color: #007700">&gt;&amp;</span><span style="color: #0000BB">nbsp</span><span style="color: #007700">;&lt;/</span><span style="color: #0000BB">th</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">thead</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tbody</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"label"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Title</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"label"</span><span style="color: #007700">&gt;</span><span style="color: #FF8000">#&nbsp;of&nbsp;Tracks&lt;/td&gt;&lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"label"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Formats</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">tbody</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">table</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;</span>
</span>
</code></div><p>
	<br />
This conditional displays the comparison table labels if the template has been loaded with entry_id&#8217;s showing in the URL.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&#123;if&nbsp;segment_3&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;embed</span><span style="color: #007700">=</span><span style="color: #DD0000">"embeds/comparison_column"&nbsp;</span><span style="color: #0000BB">the_segment</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;segment_3&#125;"</span><span style="color: #0000BB">&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&#123;if&nbsp;segment_4&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;embed</span><span style="color: #007700">=</span><span style="color: #DD0000">"embeds/comparison_column"&nbsp;</span><span style="color: #0000BB">the_segment</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;segment_4&#125;"</span><span style="color: #0000BB">&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;&nbsp;&nbsp;&nbsp;<br /><br />&#123;if&nbsp;segment_5&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;embed</span><span style="color: #007700">=</span><span style="color: #DD0000">"embeds/comparison_column"&nbsp;</span><span style="color: #0000BB">the_segment</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;segment_5&#125;"</span><span style="color: #0000BB">&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">body</span><span style="color: #007700">&gt;<br />&lt;/</span><span style="color: #0000BB">html</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>These conditionals pull in the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fembedding.html">embedded template</a> that displays a column.&nbsp; Since the columns need to be identical and only need to look at a different segment for the right entry_id to pull content for, I created an embedded template and just pass the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Furl_segments.html">segment variable</a> as an <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fembedding.html%23embed-variables-for-the-embedded-template">embed variable</a>.&nbsp; While the comparison column in this tutorial is simple, the odds are that on a production site it would be much more complex and you might as well only create that table once.</p>

<p><strong>The embeds/comparsion_column Template</strong>
</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;weblog</span><span style="color: #007700">=</span><span style="color: #DD0000">"releases"&nbsp;</span><span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"1"&nbsp;</span><span style="color: #0000BB">entry_id</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;embed:the_segment&#125;"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"trackbacks|categories|member_data|pagination"&nbsp;</span><span style="color: #0000BB">dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">table&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"compare"&nbsp;</span><span style="color: #0000BB">border</span><span style="color: #007700">=</span><span style="color: #DD0000">"1"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">thead</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">th</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">img&nbsp;src</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;releases_album_thumb&#125;"&nbsp;</span><span style="color: #0000BB">title</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;title&#125;"&nbsp;</span><span style="color: #0000BB">alt</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;title&#125;"&nbsp;</span><span style="color: #007700">/&gt;&lt;/</span><span style="color: #0000BB">th</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">thead</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tbody</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">a&nbsp;href</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;url_title_path='releases/detail'&#125;"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;releases_number_tracks&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;releases_formats&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;item</span><span style="color: #007700">==</span><span style="color: #DD0000">"MP3"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">img&nbsp;src</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;site_url&#125;images/interface/release_itunes.png"&nbsp;</span><span style="color: #0000BB">alt</span><span style="color: #007700">=</span><span style="color: #DD0000">"MP3"&nbsp;</span><span style="color: #007700">/&gt;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;item</span><span style="color: #007700">==</span><span style="color: #DD0000">"CD"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">img&nbsp;src</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;site_url&#125;images/interface/release_cd.png"&nbsp;</span><span style="color: #0000BB">alt</span><span style="color: #007700">=</span><span style="color: #DD0000">"CD"&nbsp;</span><span style="color: #007700">/&gt;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;item</span><span style="color: #007700">==</span><span style="color: #DD0000">"LP"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">img&nbsp;src</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;site_url&#125;images/interface/release_lp.png"&nbsp;</span><span style="color: #0000BB">alt</span><span style="color: #007700">=</span><span style="color: #DD0000">"LP"&nbsp;</span><span style="color: #007700">/&gt;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">releases_formats&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">td</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">tr</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">tbody</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">table</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;&nbsp;</span>
</span>
</code></div>

<p>Pretty straightforward here, we just use the passed-in variable to determine what URL segment to grab the entry_id from.&nbsp; </p>

<p><strong>Wrapping Up</strong><br />
So there you have it - with a small bit of javascript together with native ExpressionEngine tools like <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Furl_segments.html">segment variables</a>, <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Fconditionals.html">conditionals</a>, <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fembedding.html">embedded templates</a>, and <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fembedding.html%23embed-variables-for-the-embedded-template">embed variables</a>, you can pretty quickly pull entries from a channel and display them in a side-by-side comparison table for happy users.
</p>
		]]>
	</description>       

      <dc:subject>Advanced Coding</dc:subject>
      <dc:date>2012-02-04T12:56:30+00:00</dc:date>
    </item>

    <item>
      <title>Weekly Archives in ExpressionEngine</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/weekly-archives-in-expressionengine/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/weekly-archives-in-expressionengine/#When:15:01:35Z</guid>
	<description>
		<![CDATA[
			 <p>I recently had a client site come through with a design that featured news items on the home page.&nbsp; Nothing unusual there.&nbsp; But the design also had a large drop-down that allowed users to select the week they wanted to see news for.</p>

<p>The functionality I needed was exactly the same as the native <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Farchive_month_links.html">Monthly Archive</a> tagset, but for weeks rather than months.</p>

<p>If you&#8217;e used the Monthly Archive tagset, you know that it creates links that take advantage of the <a href="http://www.train-ee.com/courseware/free-tutorials/comments/dynamic-off-explained">dynamic aspect</a> of the exp:channel:entries tag in that the Monthly Archive tag generates URLs that have month and year as URL segments (example.com/blog/2011/06/) and that URL structure is how an exp:channel:entries tag running in dynamic mode knows which entries to pull.</p>

<p>Pretty cool, but for me it means that the means by which EE can pull monthly archives is pretty well-baked into the system and not easily tweaked for my purposes.&nbsp; Searching the EE aftermarket reveals a <a href="http://gotolow.com/addons/low-yearly-archives">Yearly Archives</a> plugin by Low, but that&#8217;s making the bucket bigger rather than smaller.&nbsp; Not finding any other add-ons I had actually written and sent an email to the client saying I couldn&#8217;t do the weekly drop-downs and had setup the page to use a monthly drop-down and the native Monthly Archives function and that would have to do until/unless I &#8220;had a bright idea&#8221;.</p>

<p>And - you guessed it - it wasn&#8217;t 1/2 hour after sending that email when I had that bright idea.&nbsp; Or at least enough of a spark to get me doing the experimentation that led to a solution. Below is the solution I came up with - it&#8217;s working on our development system with some test content.&nbsp; It&#8217;s not a perfect solution - let&#8217;s look at the code and then I&#8217;ll point out my concerns with it (note that this is a simplified version not involving a drop-down):</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Choose&nbsp;Week</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">This&nbsp;creates&nbsp;a&nbsp;</span><span style="color: #007700">list&nbsp;</span><span style="color: #0000BB">of&nbsp;weeks&nbsp;that&nbsp;contain&nbsp;news&nbsp;entries</span><span style="color: #007700">.&nbsp;&nbsp;</span><span style="color: #0000BB">The&nbsp;links&nbsp;it&nbsp;builds&nbsp;are&nbsp;to&nbsp;the&nbsp;same&nbsp;template&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">this&nbsp;code&nbsp;appears&nbsp;on<br />The&nbsp;week&nbsp;number&nbsp;is&nbsp;appended&nbsp;onto&nbsp;the&nbsp;URL&nbsp;</span><span style="color: #007700">for&nbsp;use&nbsp;</span><span style="color: #0000BB">in&nbsp;the&nbsp;next&nbsp;loop&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"news"&nbsp;</span><span style="color: #0000BB">orderby</span><span style="color: #007700">=</span><span style="color: #DD0000">"date"&nbsp;</span><span style="color: #0000BB">sort</span><span style="color: #007700">=</span><span style="color: #DD0000">"desc"&nbsp;</span><span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"52"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"member_data|pagination|categories|custom_fields"&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;date_heading&nbsp;display</span><span style="color: #007700">=</span><span style="color: #DD0000">"weekly"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">a&nbsp;href</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;path='news/date'&#125;/&#123;week_date&nbsp;format="</span><span style="color: #007700">%</span><span style="color: #0000BB">W</span><span style="color: #DD0000">"&#125;"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Week&nbsp;&#123;week_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%F&nbsp;%d&nbsp;%Y"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">br&nbsp;</span><span style="color: #007700">/&gt;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">date_heading&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br /><br /></span><span style="color: #007700">&lt;</span><span style="color: #0000BB">hr&nbsp;</span><span style="color: #007700">/&gt;<br /><br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">This&nbsp;loop&nbsp;lists&nbsp;the&nbsp;entries&nbsp;</span><span style="color: #007700">for&nbsp;</span><span style="color: #0000BB">the&nbsp;selected&nbsp;week&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"news"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"member_data|pagination|categories|custom_fields"&nbsp;</span><span style="color: #0000BB">orderby</span><span style="color: #007700">=</span><span style="color: #DD0000">"date"&nbsp;</span><span style="color: #0000BB">sort</span><span style="color: #007700">=</span><span style="color: #DD0000">"asc"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">Compare&nbsp;week_date&nbsp;of&nbsp;entry&nbsp;to&nbsp;number&nbsp;appearing&nbsp;in&nbsp;url&nbsp;</span><span style="color: #007700">and&nbsp;</span><span style="color: #0000BB">show&nbsp;</span><span style="color: #007700">if&nbsp;</span><span style="color: #0000BB">a&nbsp;match&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;&#123;week_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%W"</span><span style="color: #0000BB">&#125;&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">segment_3&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;title&#125;&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">&#123;entry_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%F&nbsp;%d&nbsp;%Y"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">br&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;&nbsp;</span>
</span>
</code></div>

<p>So, two loops.&nbsp; Let&#8217;s look at the first one:</p>

<p><strong>Date Heading</strong><br />
ExpressionEngine has a blogging heritage (although that&#8217;s less obvious as time goes on).&nbsp; One of the parameters for the workhorse Channel Entries tag pair is the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3Duser_guide%2Fmodules%2Fchannel%2Fvariable_pairs.html%23var_date_heading">date_heading</a> tag that allows you to group channel entries in certain time-buckets (daily, weekly, monthly, etc).&nbsp; The functionality it&#8217;s bringing to the table here is letting me build a list of weeks that have entries.&nbsp; </p>

<p><strong>Week Date</strong><br />
I&#8217;m using the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fvariables.html%23var_week_date">week_date</a> variable here - I think for the first time ever in an EE project.&nbsp; The week_date variable establishes the starting point for the week-bucket to group our entries into.&nbsp; It defaults to starting weeks on Sundays, if you want to change that use the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3Duser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_start_day">start_day</a> parameter.</p>

<p><strong>Link with Custom Segment</strong><br />
The final point of this first loop is to get the unique week number into the URL.&nbsp; I&#8217;m doing that by taking advantage of EE&#8217;s <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Furl_segments.html">segment variables</a>.&nbsp; To create the link I&#8217;m just appending on a custom segment to the normal link built by the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3Duser_guide%2Ftemplates%2Fglobals%2Fpath.html">path variable</a>.</p>

<p>The first loop nets me a list of linked weeks that have entries in them.&nbsp; Clicking one of the links refreshes the page but with a week number now appearing in the URL - now let&#8217;s look at goes on in the second loop.</p>

<p>This is pretty straightforward - we set dynamic to off so this tag ignores the URL.&nbsp; Then it loops through all entries in the news channel and compares the week of the entry date to the week number appearing in the URL.&nbsp; If it&#8217;s a match the title is shown.</p>

<p><strong>Performance?</strong><br />
My only concern with this approach is performance.&nbsp; In my case I don&#8217;t expect the news channel to have thousands of entries but rather dozens with maybe 8-10 entries per week. This particular project is also not a public one, but rather with a couple of dozen targeted and logged in users.&nbsp; So for me I think the performance will be OK.&nbsp; If your project requirements are different this approach may need some stress testing before using.</p>

<p><strong>Not Quite Done</strong><br />
The above code works great after a week has been chosen, but I also needed the page to display the current week&#8217;s news by default.&nbsp; Here&#8217;s my revised code:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Choose&nbsp;Week</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h3</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">This&nbsp;creates&nbsp;a&nbsp;</span><span style="color: #007700">list&nbsp;</span><span style="color: #0000BB">of&nbsp;weeks&nbsp;that&nbsp;contain&nbsp;news&nbsp;entries</span><span style="color: #007700">.&nbsp;&nbsp;</span><span style="color: #0000BB">The&nbsp;links&nbsp;it&nbsp;builds&nbsp;are&nbsp;to&nbsp;the&nbsp;same&nbsp;template&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">this&nbsp;code&nbsp;appears&nbsp;on<br />The&nbsp;week&nbsp;number&nbsp;is&nbsp;appended&nbsp;onto&nbsp;the&nbsp;URL&nbsp;</span><span style="color: #007700">for&nbsp;use&nbsp;</span><span style="color: #0000BB">in&nbsp;the&nbsp;next&nbsp;loop&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"news"&nbsp;</span><span style="color: #0000BB">orderby</span><span style="color: #007700">=</span><span style="color: #DD0000">"date"&nbsp;</span><span style="color: #0000BB">sort</span><span style="color: #007700">=</span><span style="color: #DD0000">"desc"&nbsp;</span><span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"52"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"member_data|pagination|categories|custom_fields"&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;date_heading&nbsp;display</span><span style="color: #007700">=</span><span style="color: #DD0000">"weekly"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">a&nbsp;href</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;path='news/date'&#125;/&#123;week_date&nbsp;format="</span><span style="color: #007700">%</span><span style="color: #0000BB">W</span><span style="color: #DD0000">"&#125;"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Week&nbsp;&#123;week_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%F&nbsp;%d&nbsp;%Y"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&lt;</span><span style="color: #0000BB">br&nbsp;</span><span style="color: #007700">/&gt;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">date_heading&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br /><br /></span><span style="color: #007700">&lt;</span><span style="color: #0000BB">hr&nbsp;</span><span style="color: #007700">/&gt;<br /><br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">This&nbsp;portion&nbsp;of&nbsp;the&nbsp;code&nbsp;builds&nbsp;the&nbsp;resulting&nbsp;</span><span style="color: #007700">list&nbsp;</span><span style="color: #0000BB">news&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&#123;if&nbsp;segment_3&nbsp;</span><span style="color: #007700">==</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;&nbsp;&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">No&nbsp;week&nbsp;number&nbsp;is&nbsp;in&nbsp;the&nbsp;URL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">so&nbsp;this&nbsp;is&nbsp;the&nbsp;</span><span style="color: #007700">default&nbsp;</span><span style="color: #0000BB">view&nbsp;before&nbsp;choosing&nbsp;a&nbsp;different&nbsp;week&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"news"&nbsp;</span><span style="color: #0000BB">display_by</span><span style="color: #007700">=</span><span style="color: #DD0000">"week"&nbsp;</span><span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"1"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"categories|member_data|pagination|custom_fields"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;title&#125;&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">&#123;entry_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%F&nbsp;%d&nbsp;%Y"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">br&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&#123;if&nbsp;segment_3&nbsp;</span><span style="color: #007700">!=</span><span style="color: #DD0000">""</span><span style="color: #0000BB">&#125;&nbsp;&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">Specific&nbsp;week&nbsp;has&nbsp;been&nbsp;chosen&nbsp;so&nbsp;week&nbsp;number&nbsp;is&nbsp;appearing&nbsp;in&nbsp;URL&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"&nbsp;</span><span style="color: #0000BB">channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"news"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"member_data|pagination|categories|custom_fields"&nbsp;</span><span style="color: #0000BB">orderby</span><span style="color: #007700">=</span><span style="color: #DD0000">"date"&nbsp;</span><span style="color: #0000BB">sort</span><span style="color: #007700">=</span><span style="color: #DD0000">"asc"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;</span><span style="color: #007700">!--&nbsp;</span><span style="color: #0000BB">Compare&nbsp;week_date&nbsp;of&nbsp;entry&nbsp;to&nbsp;number&nbsp;appearing&nbsp;in&nbsp;url&nbsp;</span><span style="color: #007700">and&nbsp;</span><span style="color: #0000BB">show&nbsp;</span><span style="color: #007700">if&nbsp;</span><span style="color: #0000BB">a&nbsp;match&nbsp;</span><span style="color: #007700">--</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;&#123;week_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%W"</span><span style="color: #0000BB">&#125;&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">segment_3&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;title&#125;&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">&#123;entry_date&nbsp;format</span><span style="color: #007700">=</span><span style="color: #DD0000">"%F&nbsp;%d&nbsp;%Y"</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">br&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;</span>
</span>
</code></div>

<p>The last loop is the same, just wrapped in the conditional that looks for a week having been selected.&nbsp; The newly-added middle loop runs if no date has been selected and the key there is the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3Duser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_display_by">display_by</a> parameter that returns a single week&#8217;s worth of entries.&nbsp; I may also have to use the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_show_current_week">show_current_week</a> parameter but I&#8217;m not sure yet and am waiting for the system to be used more to see if the right results are returned.</p>

<p>So there&#8217;s my &#8220;bright idea&#8221; for weekly archives in ExpressionEngine.&nbsp; Now if I&#8217;d just had it before telling the client it couldn&#8217;t be done&#8230;</p>

<p>
</p>
		]]>
	</description>       

      <dc:subject>Advanced Coding</dc:subject>
      <dc:date>2011-09-23T15:01:35+00:00</dc:date>
    </item>

    <item>
      <title>Pages Module 4 &#45; Eleven Ways to Pimp Pages with Add&#45;ons</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-4-eleven-ways-to-pimp-pages-with-add-ons/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-4-eleven-ways-to-pimp-pages-with-add-ons/#When:18:51:22Z</guid>
	<description>
		<![CDATA[
			<p>In the final entry in this series we&#8217;ll take a look at what&#8217;s currently available in the form of add-ons to extend the native functionality of the ExpressionEngine <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module</a>.&nbsp; 
</p> <p><strong>Disclaimer</strong><br />
I haven&#8217;t worked with all of these add-ons and this post is not meant to be an in-depth review of what they do and how well they work.&nbsp; I am currently using one of them on a client build so can comment more deeply about my experience with that one.&nbsp; The list below is in a relatively simple to complex order starting first with Accessories and other little UI helpers and moving towards Add-ons like Taxonomy and Structure that can radically alter the way you work with ExpressionEngine.</p>

<ul>
<li><a href="http://devot-ee.com/add-ons/pages-autocomplete/">Pages Autocomplete</a> - Free<br />According to it&#8217;s developer &#8220;Pages Autocomplete is a simple accessory that turns the &#8216;Pages URI&#8217; field on the publish page into an autocomplete text input.&#8221;</li>
<li><a href="http://devot-ee.com/add-ons/page-helper/">Page Helper</a> - $7<br />One of the challenges with the Pages Module is that the Page URI field has no help - it&#8217;s entirely up to your users to enter a correct and valid path and title.&nbsp; To ease this process Page Helper lets users select a parent page, then pulls the URL title from the entry.&nbsp; These elements get put together to form the Page URI.</li>
<li><a href="http://devot-ee.com/add-ons/plates/">&#8216;Plates</a> - $10<br />Along with a Page URI there is also the template choice to worry about clients getting wrong.&nbsp; According to it&#8217;s developer &#8220;This fieldtype for ExpressionEngine 2 is a drop in replacement for the native Pages Module or Structure Module ‘Template’ field. No longer do you have to present your client with a confusing + long drop down list of templates to choose from. With ‘Plates you can give your templates meaningful names, thumbnail previews and publish notes.&#8221;</li>
<li><a href="http://devot-ee.com/add-ons/mx-extended-content-menu/">MX Extended Content Menu</a> - Free<br />While the main purpose of this Add-on isn&#8217;t Pages Module related, a secondary function of it is building a Control Panel submenu for your Pages Entries&#8212;as a way of getting to them quickly for editing.</li>
<li><a href="http://devot-ee.com/add-ons/easy-page-links/">Easy Page Links</a> - Free<br />Sometimes making a content-based link from one entry to another is a harder process than it should be in ExpressionEngine - mainly because content doesn&#8217;t normally get directly to an output URL. The Pages Module does that mapping however, so this accessory &#8220;extends the functionality of the default link HTML formatting button. The link button will now open a modal window which lists the current pages from the Pages module and also has a text input field for custom URLs&#8221;.</li>
<li><a href="http://devot-ee.com/add-ons/crumbum/">CrumBum</a> - Free<br />Over the years I&#8217;ve seen many requests for an automated way to build breadcrumb trails in ExpressionEngine.&nbsp; If you aren&#8217;t using the Pages Module that&#8217;s pretty tough to do - but if you are using Pages then this add-on could prove handy.&nbsp; According to it&#8217;s developer &#8220;Crumbum is an ExpressionEngine 2 and 1 plugin that automatically generates breadcrumbs in your templates based on the URL structure of entries managed by the Expression Engine Pages Module&#8221;.</li>
<li><a href="http://devot-ee.com/add-ons/better-pages/">Better Pages</a> - $15<br />Better Pages can limit Pages templates to only those that are actually useful for a specific custom field group.&nbsp; You can add thumbnails for your templates to make selection even more intuitive, and it will narrow fields displayed on the publish/edit screen based on which template is selected.</li>
<li><a href="http://devot-ee.com/add-ons/navee/">NavEE</a> - $35<br />NavEE lets you manage multiple navigation bars using drag &amp; drop to sort them.&nbsp; It can dynamically apply active classes applied to either standard nested lists or custom HTML, generate Breadcrumbs, and more.</li>
<li><a href="http://devot-ee.com/add-ons/taxonomy/">Taxonomy</a> - $25<br />According to it&#8217;s developer Taxonomy &#8220;is a navigation/breadcrumb building tool which uses nested sets to control hierarchy.&#8221;&nbsp;  Taxonomy lets you build links either using or not using the Pages URIs from the native Pages Module.&nbsp; You can either build your Nav and then choose entries to assign to that navigation item, or use the included Fieldtype to assign an entry into the navigation right from the Publish page.&nbsp; I&#8217;m currently using Taxonomy on a client site - see my comments after this laundry list.</li>
<li><a href="http://devot-ee.com/add-ons/blueprints/">Blueprints</a> - $35<br />According to it&#8217;s developer &#8220;Blueprints lets you take control of your Publish Layouts and take Member Groups out of the equation. It is designed let you create Publish Layouts based on templates, not Member Groups. No longer will you have to tell your client &#8220;Ignore this custom field, it won&#8217;t display in Template A, but works in Template B&#8221; or, &#8220;Ignore all these templates in the drop down, just use Template B or Template C for this Channel&#8221;. Nor will you have to create different channels for different page layouts. You can create a single &#8220;Pages&#8221; channel, assign it custom fields, and use that one channel for all your page types.&#8221;</li>
<li><a href="http://devot-ee.com/add-ons/structure/">Structure</a> - $65<br />No list of Pages Module related add-ons would be complete without the <a href="http://belikewater.ca/blog/entry/structure/">ever-controversial</a> Structure Module. According to it&#8217;s developer &#8220;Structure is a powerful add-on that lets you create pages, generate navigation, manage content through a simple interface and build robust sites faster than ever. It forgoes the current template_group/template setup and creates “static” and “listing” pages that are all editable through a tree sitemap view. Now, traditional page style content and multiple entry pages can live within the same area.&#8221;&nbsp;  I&#8217;ve yet to have a project that felt right for Structure, but know that there are many in the EE community who wouldn&#8217;t build and EE site without it.</li> 
</ul>

<p><strong>Taxonomy Use Case</strong><br />
I mentioned above that I&#8217;m using <a href="http://devot-ee.com/add-ons/taxonomy">Taxonomy</a> on a current client project so I wanted to fill in a bit of the reasons why and comment about how it&#8217;s gone so far.&nbsp; </p>

<p>The project started with an EE 1x site that I didn&#8217;t build.&nbsp; It was done a few years ago by an agency that has since closed it&#8217;s doors.&nbsp; I&#8217;m not sure if this particular site was one of their first ExpressionEngine jobs, but there were some puzzling aspects to how it went together.&nbsp; For example, the Template Library was filled with page-specific templates that were all exactly the same, save for the fact that they specified a different entry_id to pull for content.&nbsp; I&#8217;m not sure the developer fully understood how ExpressionEngine works <a href="http://www.train-ee.com/courseware/free-tutorials/comments/dynamic-off-explained/">dynamically with URL&#8217;s</a>.&nbsp; Every time they needed a new page on the site, an existing template would be copied and the hardcoded entry_id changed in to pull the newly published content.&nbsp; </p>

<p>In addition to the template mess the other aspect of the site was that one weblog was storing content for multiple sections of the site.&nbsp; About Us content was stored in a catch-all &#8220;Pages&#8221; weblog along with more business-focused content (and the templates sorted it all by using the hardcoded entry ID&#8217;s).&nbsp; Now throw in the main reason for my involvement - the client wanted to reshuffle the site&#8217;s information architecture to reflect an updated way of communicating their business structure.&nbsp; And by the way, can we keep the amount of content editing &amp; reshuffling to a minimum?</p>

<p>Enter Taxonomy.&nbsp; With it I can keep the content stored the way it is and let the client assign existing entries into the revised navigation structure using the Control Panel tools the Taxonomy Module provides. After a bit of phone training they seem comfortable using the Taxonomy fieldtype to also assign newly published content into the navigation structure.&nbsp; I&#8217;ve got them working with just one menu so we&#8217;ll see how things go when I add another - but during the training they were quite enthusiastic about being able to control their navigation using the drag &amp; drop interface Taxonomy provides.</p>

<p>While working with Taxonomy I&#8217;ve run across the odd broken link in the documentation and did have to apply one change to the code itself (which was included in a subsequent release). Developer Iain Urquhart has - in spite of our vast time zone differences - been very responsive to my questions and ideas for improvements to the product.&nbsp; </p>

<p><strong>And So?</strong><br />
This is the end of the line for this series covering the Pages Module.&nbsp; Have experience with these add-ons?&nbsp; Know of something that I missed?&nbsp; Feel free to comment and let me know the error of my ways&#8230;</p>

<p>
</p>
		]]>
	</description>       

      <dc:subject>Using Addons</dc:subject>
      <dc:date>2011-07-14T18:51:22+00:00</dc:date>
    </item>

    <item>
      <title>Pages Module 3 &#45; How Others Are Using It</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-3-how-others-are-using-it/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-3-how-others-are-using-it/#When:18:35:01Z</guid>
	<description>
		<![CDATA[
			<p>This is part 3 of a 4 installment series on the ExpressionEngine <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module</a>. <a href="http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-1-an-introduction-and-history/">Part 1</a> covers an introduction and history.&nbsp; <a href="http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-2-installing-using-and-coding/">Part 2</a> covers installing, using and coding.&nbsp; Here in part 3 we&#8217;ll look at what other developers are using the Pages Module for.
</p> <p>Sometimes the best way to see if a particular feature is valuable or not is to look at what use others have found for it.&nbsp; I&#8217;ll include my use of the Pages Module at the end of this entry but thought I would also post some responses from other EE developers here as well.</p>

<p>Note that many of the comments around using the Pages Module were interspersed with comments about using some of the related add-ons, which I want to cover in the next and final chapter on this series.&nbsp; My editing may be a bit heavy handed but I wanted to focus on just the Pages related portions of the comments here.</p>

<blockquote><p>I&#8217;m using Pages module now to simply give me URL&#8217;s without the template_group in the URL structure. I&#8217;m using a static/index template for my static pages and then with the Pages module I can specify &#8220;/about&#8221; to be the Pages URL and get an nice looking URL like domain.com/about rather than domain.com/static/about. Clients will still edit the entries in the Edit menu like usual. So, my use of the pages module is pretty basic.&nbsp; <em>via <a href="http://www.deronsizemore.net/">Deron Sizemore</a></em></p></blockquote>

<blockquote><p>I&#8217;m using the pages module on a complex site I&#8217;m building right now. Most of the content consists of 4 different channels in different sections, but they also have pages like, About Us, Terms of Service, Privacy Policy, Contact Us, etc. These pages fall outside the regular norm of continual publication. That&#8217;s where I find the pages module is useful. <em>via <a href="http://bransinanderson.com/">Bransin Anderson</a></em></p></blockquote>

<blockquote><p>I use the Ellislab Pages module a lot now, but my use is probably not typical. I use it for just one purpose: as a way of allowing editors to have fine-grained control of their URLs. I describe the Pages tab as a way of overriding what the default url would otherwise be for that particular entry. This is useful not just for SEO purposes, but also allows the Marketing department to send out short, friendly URLs in mailings and offline media. I don&#8217;t typically give access to the back end of the Pages module (the bit with the hierarchical listing), because in this context it&#8217;s misleading and somewhat useless. I like this approach because it feels like progressive enhancement: I could switch the module off at any time and the site would still work fine - I have no reliance on it. <em>via <a href="http://www.jamessmith.co.uk/">James Smith</a></em></p></blockquote>

<p>As for me, I&#8217;ve only used the Pages module to any extent on two sites and in both cases the use was the same.&nbsp; These clients wanted one-off pages that didn&#8217;t exist in the navigation on the site and wanted to be able to specify the URL that the page appeared at.&nbsp; They were usually doing a specific marketing campaign where the URL was going to appear in print so it needed to be as short as possible.&nbsp; The content on the page also needed to be flexible.&nbsp; I ended up creating dedicated &#8220;pages&#8221; channels, with one custom field for &#8220;content&#8221;.&nbsp; That field was set to &#8220;none&#8221; for formatting, which allowed the clients to drop in any HTML for any type of media - Flash pieces, videos, photos and text, or survey forms where another app generated the HTML. In both cases the clients were very HTML savvy and I wasn&#8217;t concerned that they were going to publish a broken page.</p>

<p>In both cases the client were happy with what the Pages Module did for them - which was essentially work outside of the carefully crafted content management rules we had put in place for the rest of the site.</p>

<p>How about you - have you found a use for the native Pages Module not listed here?
</p>
		]]>
	</description>       

      <dc:subject>Using Addons</dc:subject>
      <dc:date>2011-07-07T18:35:01+00:00</dc:date>
    </item>

    <item>
      <title>Pages Module 2 &#45; Installing, Using and Coding</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-2-installing-using-and-coding/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-2-installing-using-and-coding/#When:16:51:05Z</guid>
	<description>
		<![CDATA[
			<p>In the <a href="http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-1-an-introduction-and-history/">first installment</a> of this series we looked at an introduction to and history of the ExpressionEngine <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module</a>.&nbsp; This post will build on that foundation by going through the process of installing the module and looking at how content authors interact with it and how to code <a href="http://www.expressionengine.com/index.php?affiliate=boyink">ExpressionEngine</a> templates to display Pages Module content.
</p> <p><strong>Installing the Pages Module</strong><br />
The <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module User Guide</a> covers the process, but overall it&#8217;s easy because the Pages Module is first-party and included with the default EE2 installation.&nbsp; Navigate to Add-ons > Modules, scan the list, find the Pages Module and click the &#8220;Install&#8221; link.&nbsp; The install process should return you to the overall list of Modules, but now the Pages Module title should be an active link, and it should be listed as &#8220;installed&#8221;.</p>

<p><br />
<strong>Configuring the Pages Module</strong><br />
The Pages Module is usable already, but you&#8217;ll want to review its <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Fconfiguration.html">configuration settings</a> to make sure it&#8217;s implemented the best way for your site. If you aren&#8217;t already there, navigate to Add-ons > Modules > Pages > Module Configuration.</p>

<p>The User Guide does a good job of explaining the settings that are available, but I&#8217;d also like to point out a couple things that aren&#8217;t immediately obvious:</p>

<ul>
<li><strong>Choosing a default Channel for Pages Entries doesn&#8217;t restrict other Channels.</strong><br /><em>All</em> channels are eligible to post entries into the Pages Module unless you configure EE otherwise.&nbsp; With the Pages Module now installed, visit a Publish page for any of your channels.&nbsp; You&#8217;ll see that the Pages Module has added a Pages tab to all of them&#8212;even the ones you&#8217;ve carefully made a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2F%2Fcp%2Fcontent%2Fpublish_page_layouts.html">Publish Page Layout</a> for.&nbsp; To prevent content authors from sending unexpected Channel entries into the Pages module you&#8217;ll need to first set the default, then go through and remove the Pages tab from the Publish page layout for all inappropriate Channels.</li>
<li><strong>You can only choose one default Channel</strong><br />If you have more than one Channel storing Pages Entries you&#8217;ll need to <em>not</em> set a default, because then EE will hide the list of channels when you click &#8220;Create Page&#8221; from the Pages interface.</li>
<li><strong>You can set a default template, but you can&#8217;t hide the rest</strong><br /> You will be exposing your template library to content authors and most times there is one right &#8220;Pages&#8221; template choice and a whole lot of wrong ones.</li>
<li><strong>The Pages screen is buried</strong><br />The Pages Module does not change your top-level EE Control Panel navigation, so it&#8217;s best to use the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fcp%2Fmy_account%2Findex.html">My Account</a> area customization abilities to add a top-level navigation option to the Pages screen.</li>
</ul>

<p><br />
<strong>Pages Module Use for Content Authors</strong><br />
There are two workflows to creating a &#8220;Pages Entry&#8221; - you either start from the normal Publish menu or from the new Pages Screen. There is little difference - either way you have to choose a channel to store the Pages Entry, enter the content, and then do two things that makes a Pages entry unique; chose an output template and assign a &#8220;Pages URI&#8221;.</p>

<p><strong>Wait, what?</strong><br />
Output template and URI?&nbsp; </p>

<p>This is where the Pages Module gets both potentially powerful and potentially confusing depending on your project and your content authors.&nbsp; We&#8217;ll get to template coding in a moment, but one of the advantages of the Pages Module is that you can feed one template with content stored in different channels with different url_titles or entry_id&#8217;s all through one template, without having to re-code the template or put in a bunch of conditionals and segment variables, and without final url implications.</p>

<p>Remember where the Pages Module User Guie said one of the features was &#8220;Use virtually any URL to display the page&#8221;?&nbsp; The &#8220;Page URI&#8221; field is where that feature comes to fruition. You simply enter the address you want this content to be found at (following some <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fcp%2Fcontent%2Fpublish.html%23tab_pages">simple guidelines</a>).&nbsp; ExpressionEngine will append your value here to your site domain and index.php (if you haven&#8217;t removed it) and use that as the final URL for this content.&nbsp; For example, if you specify a Page URI of:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep&nbsp;</span>
</span>
</code></div>

<p>Then your final URL (assuming you haven&#8217;t used .htaccess to remove index.php) would be:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">http</span><span style="color: #007700">:/</span><span style="color: #0000BB">www</span><span style="color: #007700">./</span><span style="color: #0000BB">yourdomainhere</span><span style="color: #007700">.</span><span style="color: #0000BB">com</span><span style="color: #007700">/</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep&nbsp;</span>
</span>
</code></div>

<p><strong>Pages Hierarchy</strong><br />
The Pages Module will display a hierarchy in the EE Control Panel if you&#8217;ve configured it to and have Pages assigned URI&#8217;s that contain hierarchy.&nbsp; To see how it works first visit the Pages Module configuration screen and set &#8220;Display of URIs on Module Homepage&#8221; to &#8220;Nested&#8221;.&nbsp; Now create a couple of Pages entries with URL&#8217;s along the lines of:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep<br /></span><span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep</span><span style="color: #007700">/</span><span style="color: #0000BB">seats<br /></span><span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep</span><span style="color: #007700">/</span><span style="color: #0000BB">rollcage<br /></span><span style="color: #007700">/</span><span style="color: #0000BB">mikes</span><span style="color: #007700">/</span><span style="color: #0000BB">cool</span><span style="color: #007700">/</span><span style="color: #0000BB">jeep</span><span style="color: #007700">/</span><span style="color: #0000BB">rollcage</span><span style="color: #007700">/</span><span style="color: #0000BB">seatbelts&nbsp;</span>
</span>
</code></div>

<p>Now in the Pages Module interface you get a hierarchical view (see screenshot).<a href="http://www.train-ee.com/images/weblog/manag<a href="http://www.train-ee.com/images/weblog/pages_hierarchy.png" onclick="window.open('http://www.train-ee.com/images/weblog/pages_hierarchy.png','popup','width=916,height=327,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img class="right" src="http://www.train-ee.com/images/weblog/pages_hierarchy_thumb.png" width="250" height="86" /></a></p>

<p> Pretty cool - for some sites and content authors this may be a more helpful way of finding, editing, and viewing the content they want to edit.</p>

<p><br />
<strong>Coding Templates to Display Pages Entries</strong><br />
Again, start with the EE User Guide around <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Fdisplay_page_content.html">displaying Pages entries</a>.&nbsp; At its simplest this template can look like:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"static_pages"</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">h2</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h2</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;content&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;&nbsp;</span>
</span>
</code></div>

<p><strong>Parameters</strong><br />
The above example is admittedly a pretty simple channel:entries tag - let&#8217;s look a bit deeper at what code we can, can&#8217;t, and should do to display a Pages entry.&nbsp; According to the User Guide:
</p><blockquote><p>On the template assigned to a Page entry, use a normal Channel Entries tag with any parameters and variables that you desire to display the entry</p></blockquote>

<p>This statement paints with a pretty broad brush and I&#8217;d argue that it&#8217;s too broad.&nbsp; There are many parameters for the channel:entries tag that you wouldn&#8217;t (or couldn&#8217;t) use when displaying a Pages entry:</p>

<ul>
<li><a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_url_title">url_title</a></li>
<li><a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_entry_id">entry_id</a></li>
<li><a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_offset">offset</a></li>
<li><a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_orderby">orderby</a></li>
<li><a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_search">search</a></li>
</ul>

<p>That&#8217;s just a quick and non-inclusive list.&nbsp; The general guideline is that any parameter you would normally use to affect what entry or entries are returned would be inappropriate on a Pages template - because the URL already determines what entry will be returned. Also any parameter that would cause the channel:entries tag to return or act on multiple entries (ID ranges, date ranges etc) would be inappropriate as well.</p>

<p>Some other parameters of note:</p>

<p><strong>disable= Parameter</strong><br />
I hate the term &#8220;best practices&#8221; - but if there are any in ExpressionEngine one of them is to use the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html">disable</a> parameter as a means to eliminate unnecessary queries generated by the channel:entries tag and as a result improve page load time.&nbsp; It&#8217;s no different when displaying a Pages entry - adding &#8220;disable=&#8220;member_data|pagination|categories&#8221; reduced the queries on my test page by 3.</p>

<p><strong>limit= Parameter</strong><br />
I often use a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_limit">limit</a> parameter on single-entry templates to ensure they only ever display one entry no matter if someone tries to manipulate the URL.&nbsp; When I tried this on my sample template I ended up with an <em>additional</em> query, so it might be best to not use it here.</p>

<p><strong>show_pages=&#8220;only&#8221;</strong><br />
This is a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fchannel%2Fparameters.html%23par_show_pages">new parameter</a> that the Pages Module brings to the table, and at first glance you might think of using it like the &#8220;limit=1&#8221; parameter to ensure that your Pages template only displays Pages entries.&nbsp; If you add it to the template, however, what you&#8217;ll get is a listing of <em>all</em> your Pages entries.&nbsp; This parameter is intended to be used to build navigation to all of your pages entries - so used in a sidebar where it would be added to a second channel:entries tag pair. Note that it essentially does two things - sets dynamic=&#8220;no&#8221; and returns only Pages entries.</p>

<p>The kicker with the show_pages parameter is that it only returns a flat list of Pages entries. No hierarchy. No sense of parents or children.&nbsp; It&#8217;s especially frustrating because you can see that hierarchy in the Control Panel but can&#8217;t get it to display on your site. The Pages Module is almost the evil identical twin of EE&#8217;s categories which will render a hierarchical list to the site but keeps all URLs flat.&nbsp; Pages will create hierarchical URLs but you can&#8217;t get EE to render a hierarchical list on the site.</p>

<p><strong>What About Variables?</strong><br />
That covers parameters, what about the other arrow in our EE-quiver - variables?&nbsp; ExpressionEngine has a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Findex.html">Number of Variable Types</a>, all of which will work within a channel:entries tag pair returning content from the Pages Module.</p>

<p>And that, my friends, is something I learned while writing this article.&nbsp; For some reason, somewhere, I got it stuck in my head that a template used to display Pages content at a Pages URL could not use segment variables in conditionals because the URL was essentially &#8220;masked&#8221;.&nbsp; I&#8217;ve said as much in numerous EE discussion forum threads.&nbsp; In coding a template to verify things I&#8217;m saying in this article, I quick threw some conditionals in like:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&#123;if&nbsp;segment_2&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"mikes"</span><span style="color: #0000BB">&#125;<br /></span><span style="color: #007700">&lt;</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Now&nbsp;display&nbsp;this&nbsp;paragraph</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;&nbsp;</span>
</span>
</code></div>

<p>And now I can&#8217;t get them to <em>not work</em>.&nbsp; I even had to go back to an EE 1 site and sure enough, works there too. I&#8217;m not sure where I got that idea from.&nbsp; Or why no one ever caught it in the forums..;) If I&#8217;ve misled you in this respect I apologize!</p>

<p><br />
<strong>What Do You Give Up?</strong><br />
My misunderstanding of segment variables aside, there are still some possible drawbacks you need to know about if setting out to use the Pages Module.&nbsp; There is a sneaky sentence in the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Fdisplay_page_content.html">Pages Module User Guide</a> that says the following:</p><blockquote><p>the page will automatically be treated as a single entry page for that page entry, so other tags on the template will need to use the dynamic=&#8220;no&#8221; parameter (if available) to display other content.</p></blockquote>

<p>Pages templates are all about displaying the Pages entry at the URL you made up.&nbsp; The casualty in this feature is you&#8217;ve lost the ability for all other tags to work in the dynamic mode that you&#8217;re used to everywhere else because that dynamic mode relies on a formulaic URL structure.&nbsp; Given the number of ways just the channel:entries tag works dynamically, this can be quite a drawback.&nbsp; Category pages, paginated content, and date archives all rely upon ExpressionEngine&#8217;s URL structure to know what content to return so would be unusable at a rendered Pages URL.&nbsp; </p>

<p><br />
<strong>What&#8217;s Next?</strong><br />
We&#8217;ve covered the history and purpose of the Pages Module.&nbsp; We&#8217;ve looked at how to install it, what it means for content authors, and how to return Pages entries from a template.&nbsp; We&#8217;ve looked how the Pages Module works with some parameters and variables, and what you give up to get the features of the Pages Module.</p>

<p>In the next (and I suspect, last) installment of this series we&#8217;ll look at how people are using the Pages Module, and what the 3rd Party Add-on market brings to the table to extend the native abilities of the Module.</p>

<p>&nbsp;</p>
		]]>
	</description>       

      <dc:subject>Using Addons</dc:subject>
      <dc:date>2011-06-06T16:51:05+00:00</dc:date>
    </item>

    <item>
      <title>Pages Module 1 &#45; an Introduction and History</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-1-an-introduction-and-history/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/pages-module-1-an-introduction-and-history/#When:17:41:17Z</guid>
	<description>
		<![CDATA[
			<p>This past week a number of the threads in the <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fforums%2F">ExpressionEngine Support Forums</a> were related to the first-party ExpressionEngine <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module</a>.&nbsp; It seemed to me that people were either trying to use it in ways it wasn&#8217;t intended to be used or were running into limitations that aren&#8217;t made clear in the documentation.&nbsp; </p>

<p>I set about to write a comprehensive article about the module - what it is, where it came from, why it was developed, what it does, what it doesn&#8217;t do, what it prevents you from doing, how people are using it, and how 3rd party developers are extending it.&nbsp; As I started putting the article together it started getting pretty long, so I&#8217;ve decided to break it up into either a 2 or 3 part series.&nbsp; This first installment covers the basics of what the Pages Module is (and isn&#8217;t) and takes a look at the history of the module with interviews from a couple of the key developers in its history.</p>

<p>What this article <em>won&#8217;t</em> do is talk in great detail about 3rd party addons like <a href="http://buildwithstructure.com">Structure</a> and <a href="http://iain.co.nz/software/docs/taxonomy/">Taxonomy</a>. While they are part of the Pages Module lineage I haven&#8217;t yet used either one of those tools and would rather not cover them without direct experience. But hey - that&#8217;s what comments are for, right?
</p> <p><strong>&#8220;What&#8217;s this stuff? Some Cereal.&nbsp; Supposed to be good for ya.&#8221;</strong><br />
So what <em>is</em> the Pages Module?&nbsp; Your first encounter with the Pages Module may be in the Addon-Ons > Modules area of ExpressionEngine where it says: </p><blockquote><p>Uses Channel Entries to make Static pages</p></blockquote><p>Oh, cool, so this module creates static .HTML files from my channel entries, which should load faster.&nbsp; This is a performance-related module then?</p>

<p>Let&#8217;s read on, now from the description from the Pages Module <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">documentation</a> where it says the module:&nbsp; 
</p><blockquote><p>allows you to easily create and maintain page content that is more akin to static content than dynamic information.</p></blockquote><p>How much more akin? Is the content stored differently somehow?&nbsp; Is the whole page managed this way, or just parts of it? Is the process for creating new &#8220;pages&#8221; different than an &#8220;entry&#8221;? Is there a difference between &#8220;content&#8221; and &#8220;information&#8221;?&nbsp; </p>

<p>Reading on: </p><blockquote><p>Additionally, these special &#8220;page&#8221; entries can be displayed with virtually any URL desired.</p></blockquote><p>Now there&#8217;s some meat. ExpressionEngine by default has a relatively prescribed URL structure.&nbsp; How you name and organize your templates and template groups has a direct effect on your generated URLs. Most times that&#8217;s fine, other times it&#8217;s a barrier to another goal. Being able to work outside that structure when desired is handy.</p>

<p>The documentation lists some additional features:
</p><blockquote><ul>
<li>Allows content authors to add and maintain pages without needing access to Templates</li>
<li>Enjoy the full flexibility of channel entries in how your &#8220;page&#8221; information is entered</li>
<li>Use virtually any URL to display the &#8220;page&#8221;</li>
</ul></blockquote>

<p>#1 is reassuring.&nbsp; I certainly don&#8217;t want content authors to need access to templates.&nbsp; But wait - does that mean if I don&#8217;t use the Pages Module they&#8217;d need access to templates? #2 just tells me I haven&#8217;t lost any flexibility - so that&#8217;s good.&nbsp; #3 re-iterates the point made above.</p>

<p><strong>So the Pages Module is&#8230;anyone?&nbsp; Anyone?</strong><br />
So some of the confusion around the Pages Module comes from the EE documentation because it doesn&#8217;t fully explain what the module is and is not.&nbsp; Here&#8217;s my take on it - the Pages Module is primarily a way to:</p>

<ul>
<li>allow content authors to define a URL to the content.</li>
<li>allow content authors to define content heirarchy by creating URLs that establish it.</li>
<li>provide content authors navigation to edit existing Page entries that reflects heirarchical URLs.</li>
<li>allow developers a way to offer content authors different &#8220;output templates&#8221; for their Pages content, without affecting URL structures.</li>
</ul>

<p><br />
The Pages Module is not:</p>

<ul>
<li>a way to have ExpressionEngine generate true static .html files from rendered content &amp; templates.</li>
<li>the only way to prevent content authors from needing access to templates.</li>
<li>a <em>significantly</em> different way for content authors create or maintain page-based content. </li>
<li>usually the basis for an entire website built in ExpressionEngine.</li>
</ul>

<p><br />
<strong>&#8220;Just sit right back and you&#8217;ll hear a tale / A tale of a fateful trip&#8221;</strong><br />
Later in this series we&#8217;ll look deeper at the ins and outs of the Pages Module, but first I wanted to to look at where it came from and why it was developed.&nbsp; </p>

<p><a href="http://www.train-ee.com/images/weblog/tome_config.png" onclick="window.open('http://www.train-ee.com/images/weblog/tome_config.png','popup','width=615,height=480,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img class="right" src="http://www.train-ee.com/images/weblog/tome_config_thumb.png" width="200" height="155" /></a><strong>Mark Huot&#8217;s Tome</strong><br />
As with many of the significant ExpressionEngine Add-ons, the Pages Module started with <a href="http://happycog.com/about/huot/">Mark Huot</a>, Technology and Development Director for Happy Cog.&nbsp; Mark wrote a module initially called &#8220;Pages&#8221;, later renamed to &#8220;Tome&#8221; after ExpressionEngine came out with its first party Pages Module.</p>

<p>Tome&#8217;s approach was to use one weblog as the Tome weblog. You&#8217;d create a category group for this weblog and use ExpressionEngine&#8217;s category management tools to establish a hierarchical structure (think one category per page).&nbsp; <a href="http://www.train-ee.com/images/weblog/manage_pages.png" onclick="window.open('http://www.train-ee.com/images/weblog/manage_pages.png','popup','width=615,height=300,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img class="right" src="http://www.train-ee.com/images/weblog/manage_pages_thumb.png" width="200" height="95" /></a>Once the hierarchy was established you would use the Tome interface to get to a node to edit the content there.&nbsp; Or, you could feed other weblog content in at a specific node by changing the module configuration, routing its output to a different template.</p>

<p>Mark graciously agreed to answer some questions about Tome as background for this article:</p>

<p><em>What was your reason for developing Tome?&nbsp; Was it for a specific client project or something you wanted to provide for the community?</em>
</p><blockquote><p>It was developed for the community. I was enjoying EE development so much I started comparing EE to other platforms. I noticed WordPress had a great &#8220;pages&#8221; feature that allowed you to create one-off static pages. EE was sorely lacking in this area. I had noticed many tutorials on how to use weblogs and nested templates to re-create this kind of functionality, but they all felt like hacks.</p>

<p>It only took a few hours to get the initial proof of concept up and running. EE&#8217;s extension hooks (at the time) were far too generous and allowed me to hook in to the very underlying functionality of the system. I was able to rewrite important aspects of the URL routing engine and generate a static page.</p></blockquote>

<p><em>What advantages did you feel Tome offered over what EE did natively?</em>
</p><blockquote><p>At the time EE didn&#8217;t offer anything like this. Its advantage was that it allowed me to break entries free from their channel and allow them to live on their own as stand alone pages.</p></blockquote>

<p><em>Did you feel Tome had downsides to being used (did it play well with segment variables, pagination, categories, embedded templates etc)?</em>
</p><blockquote><p>Yes, it had many downsides. The biggest of which being 1. my ability to support it and 2. its hacked implementation on top of EE. While I was able to get it to play nicely with most segment variables and categories, pagination was always a bear.</p></blockquote>

<p><em>How similar or different to Tome is the native Pages module?</em>
</p><blockquote><p>All in all, it was awfully darn similar. The biggest difference was the UI of the CP. I had a release just about ready to go out at the time that Pages was released which enhanced the CP UI to add expand collapse support, drag and drop support and a slew of smaller UI tweaks. Those features never saw the light of day, and unfortunately never made it into the native Pages module either.</p></blockquote>

<p><em>With the current state of EE and the addon aftermarket, how would you meet the project requirements today that caused you to create Tome at the time?</em>
</p><blockquote><p>The short answer is that I use Structure for most of my development now. It&#8217;s robust and offers a much cleaner UI for content editors to get content into EE.</p></blockquote>

<p>As an aside, Train-ee traces its roots to Tome, as some of the first tutorials I wrote were how to use native weblogs and templates to create <a href="http://www.train-ee.com/courseware/free-tutorials/category/static-content/">&#8220;static&#8221; content with dynamic navigation</a>.</p>

<p><strong>&#8220;Rumors of my assimilation are greatly exaggerated.&#8221;</strong><br />
Or not in this case.&nbsp; ExpressionEngine version 1.6 - released in <a href="http://expressionengine.com/legacy_docs/changelog.html#v160">June of 2007</a> - included a new &#8220;Pages Module&#8221; that assimilated some of Tome&#8217;s features.&nbsp; The primary ExpressionEngine Developers at the time were <a href="http://reedmaniac.com/">Paul Burdick</a> and current EllisLab President/CTO <a href="http://ellislab.com/company/team/derek_jones/">Derek Jones</a>.&nbsp; Paul Burdick handled the ExpressionEngine Pages Module and also agreed to answer some questions about it via email:</p>

<p><em>What were the reasons for developing the Pages Module?</em>
</p><blockquote><p>Mark Huot had written a very popular module called Pages that allowed one to organize content into a hierarchy while also dynamically generating navigation for those pages.&nbsp; It was extremely popular as it allowed people to create a slightly more custom site structure.&nbsp; Do not remember how it worked exactly.&nbsp;  However, there were a couple bugs that were causing EllisLab to take notice of it, specifically it killing sites with load and install/uninstall/update issues.&nbsp; Mark was working on a new version but with his client work and other responsibilities it was delayed.&nbsp; Since it was popular and seemed to fill a need, EllisLab decided to build their own version with a tighter integration in ExpressionEngine, which allowed the load to be greatly reduced.</p></blockquote>

<p><em>What advantages did you feel the Pages Module offered over how EE worked before it existed?</em>
</p><blockquote><p>The original intention was to allow users to use entries and templates to create a site structure more fitted to their needs and outside the standard template_group/template URL structure.&nbsp; Essentially, a single entry displayed by any template at any URL they dreamed up.&nbsp; Any hierarchy would be on whatever URL structure they created.&nbsp; Extremely basic functionality, honestly, but something that required modifying the core.system.php file to override the use of the Template class.&nbsp;  Also, it allowed designers to create content on the site that was only displayed on a single page (ex: an about page) that was editable in the Publish area by their content editors without needing to touch templates or global variables.</p></blockquote>

<p><em>Did you expect that people would use it as the basis for an entire site or just portions?</em>
</p><blockquote><p>Definitely portions.&nbsp; An entire site being created with Pages was not even on the radar.&nbsp; It was a rather lightweight addition to EE 1.6.</p></blockquote>

<p><em>Is there a reason the module never went further with more dedicated tag pairs for building navigation and breadcrumb trails?</em>
</p><blockquote><p>If people remember, the real effort for building ExpressionEngine 2.x started in 2007 at EllisLab.&nbsp; On some level, EllisLab and specifically the development team was spread a little bit thin the latter half of that year with ExpressionEngine 1.x, CodeIgniter, and ExpressionEngine 2.x work.&nbsp;  Derek Jones and I were the only full time developers working on ExpressionEngine for most of that year too.&nbsp; So, expanding Pages was not a priority.&nbsp;  Further, looking back at the EE 2.0 To Do list now, one of the highest priorities for ExpressionEngine 2.0 was a rewrite of the Template parser.&nbsp; And one of my goals with that was to allow more flexibility in how the site structure could be set up via templates.&nbsp;  Obviously, with my departure in early 2008 and the delays with ExpressionEngine 2.0 being released, those two goals were never realized.</p></blockquote>

<p><em>Were/are you happy with how the module currently functions? </em>
</p><blockquote><p>Looking at it now, no, I am not pleased with how it functions.&nbsp; However, I understand why it was written so simply at the time and that we were *planning* on making much more powerful functionality possible in the future.</p></blockquote>

<p><em>Do you feel there are downsides to using the Module and if so, what are they?</em>
</p><blockquote><p>Honestly, it is way too simple and not easy enough to create Pages and build a hierarchy (especially seeing the current hierarchy and adding to it).&nbsp; Once again, so much of this seems like something destined for the &#8220;Design&#8221; area in the CP, as it is a amalgamate of Publishing and Site Structure.</p></blockquote>

<p><em>What are your thoughts on how the addon market has extended the use and overall direction of the Pages Module?</em>
</p><blockquote><p>Except for Structure, I am not familiar with how the Add-On market is affecting or has been affected by Pages.&nbsp; I tried using Structure during the first EECI Conference in Leiden, but it never tickled my fancy.&nbsp; My personal needs in ExpressionEngine have always run towards the amazingly bland and simple or so extremely specific/complex that I have had to custom build my own Add-Ons or hack ExpressionEngine itself.&nbsp;  Professionally, I have not had to work with either Pages or Structure while working with Solspace.</p></blockquote>

<p><strong>What&#8217;s Next</strong><br />
In the next installment of this series we&#8217;ll cover how to install &amp; configure the Pages Module, how to code a template to display Pages Module content, and what using the Pages Module means for content authors.</p>

<p>Thanks to Mark and Paul for taking the time to respond to my questions, and thanks to Eric Barstad of <a href="http://www.shadowboxcreative.ca/">Shadow Box Creative Media</a> for supplying the Tome screen captures.
</p>
		]]>
	</description>       

      <dc:subject>Using Addons</dc:subject>
      <dc:date>2011-06-04T17:41:17+00:00</dc:date>
    </item>

    <item>
      <title>Flexible Sidebars using Playa</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/flexible-sidebars-using-playa/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/flexible-sidebars-using-playa/#When:17:35:10Z</guid>
	<description>
		<![CDATA[
			<p>This tutorial is in response to my <a href="http://boyink.com/write/show-dont-tell/">own &#8220;Show Don&#8217;t Tell&#8221;</a> article on Boyink.com where I bemoaned the number of articles promoting &#8220;must-have EE add-ons&#8221; that don&#8217;t show <em>how</em> the add-on is used.&nbsp; This article will cover the use of <a href="http://pixelandtonic.com/playa">Playa</a>, a 3rd party addon from Pixel &amp; Tonic, to create web site sidebars that are flexible in both what they contain and how the content is ordered.
</p> <p><strong>Project</strong><br />
The project at hand was school website.&nbsp; The site is fairly large with 8 main areas of content to cover it&#8217;s preschool through middle school offerings.&nbsp; I was contracted to take a new site design and power it using <a href="http://www.expressionengine.com/index.php?affiliate=boyink">ExpressionEngine</a>.</p>

<p><strong>Whoa - Old Skool?</strong><br />
The project started some time back when the released version of EE2 was relatively new, so after some discussion with the client we decided to stick with EE1 for its stability and more well-rounded market of addons. <img class="right" src="http://www.train-ee.com/images/weblog/left_column.jpg" width="116" height="421" />Don&#8217;t let that keep you from reading, as this approach to solving a similar design &amp; implementation challenge would be easy to port into EE2 by just changing the {weblog} related code to {channel}.&nbsp; </p>

<p><strong>Challenge</strong><br />
As I looked through the provided design comps I noticed that the sidebars had a number of different content elements in them.&nbsp; There were little blocks just a quote. There were photos with a blurb of text and a link.&nbsp; There were lists.&nbsp; There were Bible quotes. There were Google maps.&nbsp;  Immediately some questions starting coming to mind:
</p><ul>
<li>How many of these things are there?</li>
<li>Are they the same throughout the site, or are they different in each section of the site, or are they different at the page level?</li>
<li>Do they need to randomize?</li>
<li>Is the ordering of them always the same?</li>
<li>How much control does the end client need over these items?</li>
</ul>

<p>As expected, the client wanted very precise control (do clients ever want anything less than complete control?). They wanted to choose sidebar items and set the sort order per page. Sidebar items needed to be reusable (one element being used on a variable number of pages across the site).</p>

<p><strong>Native?</strong><br />
Could this be done with native ExpressionEngine tools?&nbsp; I quickly ran through the available tools - relationships, categories, custom fields for setting sort order, etc. It was immediately apparent that for this requirement the native EE abilities weren&#8217;t going to cut it.&nbsp; </p>

<p><strong>Look to the Aftermarket</strong><br />
I knew that Playa offered ability to multi-select select from multiple weblogs/channels and had a drag / drop interface for for ordering selected items.&nbsp; That was the Control Panel interface my client needed, no question.</p>

<p><strong>Implementation</strong>
</p><ul>
<li><strong>Content-Specific Weblogs/Channels</strong><br />I setup per-content-type weblogs/channels for each type of sidebar content (picture, quote, graphic, video, etc). Some of these content types are left or right column specific and some can be used on either side (as determined by the design).&nbsp; I named them accordingly (Sidebar Either Text Box, Sidebar Left Graphic etc).
<li><strong>Playa Fields</strong><br />I created two Playa fields in the field group storing page content - one for the left sidebar, and one for the right.</li>
<li><strong>Template Code</strong><br />Each type of content has unique markup, so the template code uses conditionals within the Playa tag pair.&nbsp; After determining what weblog/channel the result is from, the correct markup is applied to the returned content (code snippet available as a Companion File to this article)</li>
</ul>

<p><br />
<strong>Content Management Workflow</strong><br />
The client first publishes content to the proper sidebar weblog/channels.&nbsp; <img class="right" src="http://www.train-ee.com/images/weblog/playa_cp.jpg" width="350" height="205" />Once the content item has been published it&#8217;s now available to the ExpressionEngine entry that holds the main page content. Now when they create or edit a page they use the two Playa fields to find the sidebar element they want, select it, then drag &amp; drop to sort it correctly.</p>

<p><strong>Results</strong><br />
The feedback I got with the approach was fantastic - I got word that the end client was &#8220;having fun&#8221; setting up his pages. </p>

<p>Fun?&nbsp; Whodathunk!</p>

<p>Playa is a great add-on (actually a bit of a no-brainer to write this article about). I don&#8217;t use it on every site, but when the need presents itself - like on this project - it can definitely solve a requirement puzzle and help you look the hero to your clients.
</p>
		]]>
	</description>       

      <dc:subject>Using Addons</dc:subject>
      <dc:date>2011-05-18T17:35:10+00:00</dc:date>
    </item>

    <item>
      <title>Static Content?&amp;nbsp; Inconceivable!</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/static-content-inconcievable/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/static-content-inconcievable/#When:16:50:45Z</guid>
	<description>
		<![CDATA[
			 <iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/G2y8Sx4B2Sk" frameborder="0" allowfullscreen></iframe>

<p>Static pages.&nbsp; Dynamic content.&nbsp; Clean URLs.&nbsp; Databases.&nbsp; Templates.&nbsp; Flat Files.&nbsp; Publishing systems.</p>

<p>We&#8217;ve created a puzzling environment for putting content on the web, and the way different technology vendors use the same words with different meanings attached can make learning a new system a nightmare for anyone, much less someone new to the whole deal.</p>

<p>In a <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fforums%2Fviewthread%2F59799%2F%23860354">recent forum post</a> a newcomer to ExpressionEngine posted:</p>

<blockquote><p>I’ve been confused about “static” pages and “dynamic” pages so the post above this makes no sense to me. I like to use wordpress for any blogs that I do and I’ve always been told to make whatever page I want to show up better in the search engines a “static” page. Is a “static” page in wordpress the same as a “dynamic” page? 
</p></blockquote>

<p>I responded in that thread, but also wanted to post the response here on Train-ee because understanding ExpressionEngine&#8217;s approach to &#8220;static content&#8221; is fundamental to understanding how the system works, or can work.</p>

<p><strong>I Do Not Think That Word Means What You Think It Means</strong></p>

<p>Static content is confusing because there are three mindsets driving the terminology: content management,database/backend/implementation, and search engines.</p>

<p><strong>From a Content Management Perspective:</strong><br />
This perspective looks at the nature of the content rather than the implementation.&nbsp; </p>

<p>Static pages can be defined as those that are <em>not likely to change very often</em>.&nbsp; About pages. Contact Pages. Terms of Use. Write them once and they probably aren’t going to change - hence they are “static.” </p>

<p>However there is content that changes often.&nbsp; Blog index pages change whenever you post something new.&nbsp; Product content changes with new releases. Staff profile pages change when someone leaves or someone new hires on.&nbsp; Because the content changes more often it’s “dynamic”.</p>

<p><strong>From a Database / Backend / Implementation Perspective:</strong><br />
This perspective looks at the nature of how the content is stored on the server rather than the nature of the content itself - ie <em>is the content stored in a database or in a text file</em>?</p>

<p>Static pages are those where when you navigate to <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fmydomain.com%2Fabout%2Fthe_company.htm">http://mydomain.com/about/the_company.htm</a> there is a /about/ directory on the server with a text file named the_company.htm that contains HTML, CSS, and content.&nbsp; It’s “static” because the file gets created and sits on the server.</p>

<p>With EE everything past /index.php/ in the URL doesn’t necessarily exist on the server at the file level.&nbsp; When that URL is requested EE goes to its template library and creates the web page on the fly using instructions found there.&nbsp; The result only exists in the users browser - so it’s “dynamically-generated&#8221; page.&nbsp; Things get a little fuzzy here because EE allows developers to store their templates either as flat-files on the server or in the EE database - but either way those templates are not visible to end users, only the pages created by the templates.</p>

<p><strong>From a Search Engine Perspective:</strong><br />
This perspective (at least as it relates to the topic at hand) is mainly concerned with URL formations. Dynamic content has historically had ugly URLs - like something from Amazon:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">http</span><span style="color: #007700">:</span><span style="color: #FF8000">//www.amazon.com/gp/product/B0000VYDHA?ie=UTF8&amp;tag=rvou-20&amp;link_code=wql&amp;camp=212361&amp;creative=38060&nbsp;</span>
</span>
</code></div>

<p>Search engines had a harder time indexing this content, and even when it was indexed it wasn’t ranked as highly due to the ugliness of the URL (and because some of those numbers were user ids or session ids that didn’t apply to everyone navigating to that page).&nbsp; </p>

<p>What the search engine wanted instead was something like:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">http</span><span style="color: #007700">:</span><span style="color: #FF8000">//amazon.com/home_improvement/ladders/werner_folding_ladder.htm&nbsp;</span>
</span>
</code></div>

<p>Not only is the URL more &#8220;readable&#8221; by humans, the search engine can more safely assume this is a good indexable page, not likely to change, not containing use or session-specific content, and of good general interest to their users.</p>

<p><strong>Soooo&#8230;What&#8217;s &#8220;Static&#8221; Mean in ExpressionEngine?</strong><br />
From a content management perspective content can either be static or dynamic. EE handles any sort of content well, from never-changing About pages to constantly-changing Blogs. From a database/backend/implementation perspective pages are (usually) all dynamic.&nbsp; From a search engine perspective it’s the best of both worlds - dynamically generated with with clean URL structures.</p>

<p>As an EE developer it&#8217;s up to you how you want to handle the implementation of content that&#8217;s less likely to ever change:</p>

<ul>
<li>You could hard-code all static content into flat-file templates and save EE from having to constantly perform database queries to retreive the same unchanged content every time it&#8217;s requested.&nbsp; While this would be more efficient from a system perspective, it means if that content ever does change the person changing it needs access to that template. I&#8217;ve never been willing to do that for most clients, and don&#8217;t want to be on the hook for changing content on their behalf (the entire reason I got into EE to begin with). If you store your EE templates in the database then your content is stored there as well and technically not truly &#8220;static&#8221;. </li>
<li>You could put your &#8220;static&#8221; content in channels and create dedicated templates &amp; template groups to present it the same way as other dynamic content. Yes, this means the system does more work with having to query the database for content that rarely changes, but now that content is always available for clients to edit through EE&#8217;s edit interface. You can use some of EE&#8217;s caching abilities to mitigate the database work required here. There are a <a href="http://www.train-ee.com/courseware/free-tutorials/category/static-content/">number of tutorials</a> here on Train-ee showing this approach.</li>
<li>You could use ExpressionEngine&#8217;s <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fmodules%2Fpages%2Findex.html">Pages Module</a>.&nbsp; Don&#8217;t be mislead - this Module is not required to create &#8220;static pages&#8221; in ExpressionEngine, but can offer some benefits for the right project.&nbsp; Essentially once the module is installed and configured you can work outside of EE&#8217;s normal URL structures and assign your own URL to a page.&nbsp; You can also create a common template to route all of these pages through.&nbsp;  Downsides to using this module are loss of the use of segment variables (since you are essentially masking a custom URL over EE&#8217;s normal URL) and having to reveal your templates to your content editors (concerning to me because there is usually one right choice and many wrong choices). </li>
<li>You could look to third-party options like <a href="http://buildwithstructure.com/">Structure</a> or <a href="http://iain.co.nz/software/docs/taxonomy/about.txt">Taxonomy</a> to work with static content in a more advanced way.</li></ul>

<p>So don&#8217;t let the terminology fool you - with ExpressionEngine you have several tools available (both native and 3rd party) to handle any sort of content in a way that&#8217;s highly efficient &amp; effective for the end client, you as the developer, and for search engines.</p>

<p>Just a bit of cliff-climbing required to figure it all out&#8230;
</p>
		]]>
	</description>       

      <dc:subject>Static Content / Dynamic Nav</dc:subject>
      <dc:date>2011-03-03T16:50:45+00:00</dc:date>
    </item>

    <item>
      <title>Snippets or Embedded Templates?</title>
      <link>http://www.train-ee.com/courseware/free-tutorials/comments/snippets-or-embedded-templates/</link>
      <guid>http://www.train-ee.com/courseware/free-tutorials/comments/snippets-or-embedded-templates/#When:16:40:08Z</guid>
	<description>
		<![CDATA[
			<p>Ever since <a href="http://www.expressionengine.com/index.php?affiliate=boyink">ExpressionEngine 2</a> went release with <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fglobals%2Fsnippets.html">Snippets</a> I&#8217;ve been wanting to do some comparison between them and other coding approaches.
</p> <p><strong>What are Snippets?</strong><br />
The short answer is they are the EE 1x <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fdownloads%2Fdetails%2Ffresh_variables%2F">Fresh Variables</a> renamed, brought into the application by default, and given a more prominent place in the Control Panel.</p>

<p>The longer answer from the documentation page linked to above:
</p><blockquote><p>
Snippets are small bits of reusable template or tag parts. You could create a Snippet for any number of purposes, anywhere that you need to reuse a small portion of a template, including partial or complete tags, other variables, etc. Snippets add flexibility and reusability, while making it simple to make site-wide changes by editing the Snippet&#8217;s source instead of having to modify many templates.</p></blockquote>

<p>Well, yea, nothing new here, right?&nbsp; We&#8217;ve always had the ability to save a chunk of code as an embedded template and use it over and over.&nbsp; But go back and read that again.&nbsp; Snippets can contain <em>partial</em> tags.&nbsp; This is new - with embedded templates you always need to code complete tag pairs in the template to be embedded in - you can&#8217;t for example, have the calling template contain the opening exp:channel:entries tag and then store the closing /exp:channel:entries tag in the embedded template.</p>

<p>The key to this added flexibility is the parse order, or the order in which ExpressionEngine reads and executes the code you create in templates:</p>

<blockquote><p>Snippets are expanded at a very early stage on each template, making it possible for them to hold dynamic content, ExpressionEngine tags, other variables, PHP, etc. They shine when you need to reuse dynamic information, but don&#8217;t need the extra overhead of access control or separate preferences of an embedded template.</p></blockquote>

<p>In addition to the sample ideas in the docs, I wanted to explore Snippets in a different way.</p>

<p><strong>A Different Coding Approach?</strong><br />
Ever since getting familiar with Snippets I&#8217;ve been wondering if there are ways to use Snippets in place of <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Ftemplates%2Fembedding_templates.html"></a>Embedded Templates with Embed Variables, and what advantages &amp; disadvantages there might to doing so.</p>

<p>One way I commonly use Embed Templates with Embed Variables is building sidebar content.&nbsp; Sites often have lists of things in the sidebar - most recent entries, most recent comments, etc.&nbsp; Many times these lists are very similar, only differing in what channel the items are being pulled from. In these cases I&#8217;ll create one embedded template and pass in the channel name as an embed variable - so I can centralize the logic and markup of the list but still dictate which results I get in the parent template.&nbsp; This seemed like a good test case for a Snippet-based approach instead.&nbsp; Below are the two coding approaches presented and then an analysis of rendering time, memory and queries used.</p>

<p><strong>The Embedded Template Approach</strong><br />
Here is the code for my parent template:
</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Test&nbsp;Embedded&nbsp;Templates&nbsp;with&nbsp;Embed&nbsp;Variables</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">The&nbsp;following&nbsp;two&nbsp;lists&nbsp;are&nbsp;returned&nbsp;using&nbsp;one&nbsp;embedded&nbsp;template</span><span style="color: #007700">,&nbsp;and&nbsp;</span><span style="color: #0000BB">passing&nbsp;embed&nbsp;variables&nbsp;&nbsp;to&nbsp;get&nbsp;different&nbsp;results</span><span style="color: #007700">.&lt;/</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;<br /><br /></span><span style="color: #0000BB">&#123;embed</span><span style="color: #007700">=</span><span style="color: #DD0000">"embeds/latest_entries"&nbsp;</span><span style="color: #0000BB">my_channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"salads"&nbsp;</span><span style="color: #0000BB">my_path</span><span style="color: #007700">=</span><span style="color: #DD0000">"salads"</span><span style="color: #0000BB">&#125;<br /><br />&#123;embed</span><span style="color: #007700">=</span><span style="color: #DD0000">"embeds/latest_entries"&nbsp;</span><span style="color: #0000BB">my_channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"restaurants"&nbsp;</span><span style="color: #0000BB">my_path</span><span style="color: #007700">=</span><span style="color: #DD0000">"restaurants"</span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>And then here is the code for the embedded template:
</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Latest&nbsp;&#123;embed</span><span style="color: #007700">:</span><span style="color: #0000BB">my_title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"&#123;embed:my_channel&#125;"&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"5"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"custom_fields|categories|member_data|pagination"&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&#123;if&nbsp;count</span><span style="color: #007700">==</span><span style="color: #0000BB">1&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;if&nbsp;count</span><span style="color: #007700">==</span><span style="color: #0000BB">total_results&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;&nbsp;</span>
</span>
</code></div>

<p>What I like about this template is the parent template is very clean.&nbsp; The embedded template is called in twice but passed different values in the embed variables to get different lists as results.&nbsp; The programmer in me thinks of this almost like a traditional function call.&nbsp; The embedded template is a function, I pass it some different values, and it returns different results based on those values.&nbsp; The results, in this case, being a marked up unordered list of titles with a header.&nbsp; If I want to get a different number of results or link those results to different templates I can just create additional embed variables to use in the embedded template.</p>

<p><strong>The Snippet Approach</strong><br />
Here&#8217;s the same idea re-coded using a Snippets-based approach.&nbsp; With the Snippet I identified what was common about the two lists and placed that code off in a Snippet.&nbsp; The parent template then houses the first part of the of the channel:entries tag so that I can specify a different channel parameter.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Test&nbsp;Snippets</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h1</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">The&nbsp;following&nbsp;two&nbsp;lists&nbsp;are&nbsp;returned&nbsp;using&nbsp;one&nbsp;snippet&nbsp;</span><span style="color: #007700">for&nbsp;</span><span style="color: #0000BB">everything&nbsp;common&nbsp;between&nbsp;the&nbsp;two&nbsp;tag&nbsp;pairs</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">The&nbsp;only&nbsp;thing&nbsp;kept&nbsp;in&nbsp;the&nbsp;parent&nbsp;template&nbsp;is&nbsp;what&nbsp;has&nbsp;to&nbsp;be&nbsp;different&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">just&nbsp;the&nbsp;channel&nbsp;name&nbsp;in&nbsp;this&nbsp;</span><span style="color: #007700">case.&lt;/</span><span style="color: #0000BB">p</span><span style="color: #007700">&gt;<br /><br />&lt;</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Latest&nbsp;Salads</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"salads"&nbsp;</span><span style="color: #0000BB">&#123;snp_list_guts&#125;<br /><br /></span><span style="color: #007700">&lt;</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Latest&nbsp;Restaurants</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">h5</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&nbsp;channel</span><span style="color: #007700">=</span><span style="color: #DD0000">"restaurants"&nbsp;</span><span style="color: #0000BB">&#123;snp_list_guts&#125;&nbsp;</span>
</span>
</code></div>

<p>Here is the code that&#8217;s then centralized into the snp_list_guts Snippet:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">limit</span><span style="color: #007700">=</span><span style="color: #DD0000">"5"&nbsp;</span><span style="color: #0000BB">disable</span><span style="color: #007700">=</span><span style="color: #DD0000">"custom_fields|categories|member_data|pagination"&nbsp;</span><span style="color: #0000BB">dynamic</span><span style="color: #007700">=</span><span style="color: #DD0000">"no"</span><span style="color: #0000BB">&#125;<br /><br />&#123;if&nbsp;count</span><span style="color: #007700">==</span><span style="color: #0000BB">1&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br /><br /></span><span style="color: #007700">&lt;</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&#123;title&#125;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;&lt;/</span><span style="color: #0000BB">li</span><span style="color: #007700">&gt;<br /><br /></span><span style="color: #0000BB">&#123;if&nbsp;count</span><span style="color: #007700">==</span><span style="color: #0000BB">total_results&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">ul</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">if&#125;<br /><br />&#123;</span><span style="color: #007700">/</span><span style="color: #0000BB">exp</span><span style="color: #007700">:</span><span style="color: #0000BB">channel</span><span style="color: #007700">:</span><span style="color: #0000BB">entries&#125;&nbsp;</span>
</span>
</code></div>

<p>The amount of code in the Snippets parent template is almost exactly the same as sample Embedded Template parent template.&nbsp; However - call it force of habit - not seeing the complete channel:entries tag pair in one template bothers me.&nbsp; Changes to the parameters of the tag would be easy enough to handle (like if I wanted a different limit on one vs the other), but things like building a different link in the middle of the template would be harder to do - I&#8217;d have to split the one Snippet in two.</p>

<p><strong>What About Performance?</strong><br />
Regardless of the appeal of the code itself I wanted to see what performance differences there would be between the two approaches. I turned on ExpressionEngine&#8217;s <a href="http://www.train-ee.com/courseware?URL=http%3A%2F%2Fwww.expressionengine.com%2Findex.php%3Faffiliate%3Dboyink%26page%3D%2Fuser_guide%2Fcp%2Fadmin%2Fsystem_admin%2Foutput_and_debugging_preferences.html">Output Profiler</a> and found the following (all running on my local machine on a relatively small EE test site):</p>

<p><em>Snippets:</em><br />
Average Total Execution Time (10 page loads): .5414<br />
Memory: 7,549,656 bytes<br />
Queries: 23</p>

<p><em>Embeds</em><br />
Average Total Execution Time (10 page loads) .5628<br />
Memory: 7,562,520 bytes<br />
Queries: 25</p>

<p><em>Compare:</em><br />
Snippets ran ~ 4% faster.<br />
Snippets used ~1% less memory<br />
Snippets used ~ 8% fewer queries</p>

<p><strong>So?</strong><br />
The Snippet-based approach has obvious performance gains, even on my small &amp; local site.&nbsp; Those results might be more impressive on a larger site, bigger database, and more complex content.&nbsp; However I&#8217;m still somewhat ambivalent about switching to them.&nbsp; You still can&#8217;t organize Snippets into groups.&nbsp; You can&#8217;t save them as files (at least with native EE functionality, there is now a <a href="http://www.madebyhippo.com/addon-shack/view/snippet_files">third party addon</a> that lets you). And I&#8217;m still bothered by seeing EE tag pairs split between templates.&nbsp; </p>

<p>However as a means to improve performance on a site that needs it Snippets would be well-worth investigating.</p>

<p>What about you - have you found a way to use Snippets that you think is pretty cool and want to share?
</p>
		]]>
	</description>       

      <dc:subject>Advanced Coding</dc:subject>
      <dc:date>2010-12-01T16:40:08+00:00</dc:date>
    </item>

    
    </channel>
</rss>
