<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>3 Roads Media &#187; Tutorials</title>
	<atom:link href="http://www.3roadsmedia.com/blog/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3roadsmedia.com</link>
	<description>Denver Web Development, Graphic, &#38; Website Design</description>
	<lastBuildDate>Mon, 30 Jan 2012 16:28:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cufón font replacement with dropdown menus</title>
		<link>http://www.3roadsmedia.com/blog/cufon-font-replacement-with-dropdown-menus/</link>
		<comments>http://www.3roadsmedia.com/blog/cufon-font-replacement-with-dropdown-menus/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 22:06:00 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Cufón]]></category>
		<category><![CDATA[Drop-down Menus]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1941</guid>
		<description><![CDATA[On a recent client project, we decided to use Cufón font replacement on the website's main navigation. This navigation included some drop-down menus, where the main link was font replaced, but the nested list items were not. We had a few more requirements, and getting them all to work together was harder to pull off than expected. In an effort to save my fellow developers some time, I present the following solution.]]></description>
			<content:encoded><![CDATA[<p>On a recent client project, we decided to use Cufón font replacement on the website&#8217;s main navigation. This navigation included some drop-down menus, where the main link was font replaced, but the nested list items were not. We also had a couple of other requirements, and getting them all implemented was harder to pull off than I expected.</p>
<p>In an effort to save my fellow developers some time, I present the following solution.</p>
<h3>A working demonstration</h3>
<p>Before you get into the solution, you might want to <a href="http://www.3roadsmedia.com/wordpress/wp-content/themes/sketchy/demos/cufon-dropdown-demo.html">view a working demo</a>. This demo meets all of the requirements laid out in the next section.<br />
<span id="more-1941"></span></p>
<h3>The problem</h3>
<p>If you&#8217;re reading this, chances are good that you have the following three requirements:</p>
<ul>
<li>I want to do Cufón font replacement on my main navigation</li>
<li>Some or all of my navigation items will be drop-downs</li>
<li>I only want to do font replacement on the top level items; the nested list items should be unchanged</li>
</ul>
<p>Additionally, I also wanted to do the following:</p>
<ul>
<li>Apply a nice <code>text-shadow</code> to replaced text</li>
<li>Keep top level anchors highlighted while hovering on their drop-downs</li>
</ul>
<h3>The solution</h3>
<p>You can view the source code of the <a href="http://www.3roadsmedia.com/wordpress/wp-content/themes/sketchy/demos/cufon-dropdown-demo.html">demo page</a>, or read on.</p>
<h4>The HTML</h4>
<p>Your first task is to create a nice, standard, nested list:</p>
<pre><span style="color: #000080;">&lt;nav&gt; &lt;ul&gt; &lt;li&gt;</span>
         <span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>Movies<span style="color: #008000;">&lt;/a&gt;</span>
<span style="color: #000080;"> &lt;ul&gt; &lt;li&gt;</span>
               <span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>2010 Oscar Nominees<span style="color: #008000;">&lt;/a&gt;</span>
<span style="color: #000080;"> &lt;ul&gt; &lt;li&gt;</span><span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>True Grit<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt; &lt;li&gt;</span><span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>Jeff Bridges<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt; </span><span style="color: #000080;"> &lt;li&gt;</span><span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>Hailee Steinfeld<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; </span><span style="color: #008000;"> &lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>2010 Oscar Winners<span style="color: #008000;">&lt;/a&gt; </span><span style="color: #000080;"> &lt;ul&gt; &lt;li&gt;</span><span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>The King's Speech<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt; &lt;li&gt;</span><span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"#"</span><span style="color: #008000;">&gt;</span>Colin Firth<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt; </span><span class="Apple-style-span" style="color: #000080;"> &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </span><span class="Apple-style-span" style="color: #808080;"> &lt;!-- (see demo source code for the rest) --&gt; </span><span class="Apple-style-span" style="color: #000080;"> &lt;/ul&gt; &lt;/nav&gt;</span></pre>
<h4>The CSS</h4>
<p>Next up: some basic styling. This code is also available on the <a href="http://www.3roadsmedia.com/wordpress/wp-content/themes/sketchy/demos/cufon-dropdown-demo.html">demo page</a>; just view the source code to grab it.</p>
<pre><span style="color: #ff00ff;">a.fly {</span> <span style="color: #000080;">background</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#b2ab9b url(fly-arrow.gif) 175px center no-repeat</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">li:hover &gt; a {</span> <span style="color: #000080;">background</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#dfd7ca</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">color</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#c00</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">li:hover &gt; a.fly {</span> <span style="color: #000080;">background</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#dfd7ca url(fly-arrow-hover.gif) 175px center no-repeat</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul {</span>
   <span style="color: #000080;">float</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">left</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">list-style</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">none</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">margin</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0 0 50px</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">padding</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">position</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">relative</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">width</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">100%</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">z-index</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">500</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul ul {</span> <span style="color: #000080;">list-style</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">none</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">margin-left</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">padding</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul li {</span> <span style="color: #000080;">float</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">left</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">position</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">relative</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul a, nav &gt; ul a:visited {</span>
   <span style="color: #000080;">background</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#b2ab9b</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">border</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">1px solid #fff</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">border-width</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0 1px 1px 0</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">color</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">#000</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">display</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">block</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">font</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">14px Georgia, Times, serif</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">height</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">23px</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">line-height</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">23px</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">padding</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">5px 20px</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">text-decoration</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">none</span><span style="color: #ff00ff;">;</span>
   <span style="color: #000080;">width</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">160px</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul ul {</span> <span style="color: #000080;">display</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">none</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul li:hover &gt; ul { </span><span style="color: #000080;">display</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">block</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">left</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">201px</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">position</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">absolute</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">top</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0</span><span style="color: #ff00ff;">; }</span></pre>
<pre><span style="color: #ff00ff;">nav &gt; ul &gt; li:hover &gt; ul {</span> <span style="color: #000080;">left</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">0</span><span style="color: #ff00ff;">;</span> <span style="color: #000080;">top</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">34px</span><span style="color: #ff00ff;">; }</span></pre>
<h4>The JavaScript</h4>
<p>Place this code block after your main Cufón scripts (see the <a href="https://github.com/sorccu/cufon/wiki/Usage">documentation</a>):</p>
<pre>Cufon.<span style="color: #008080;">replace</span><span style="color: #000080;">(</span><span style="color: #0000ff;">'nav &gt; ul &gt; li'</span>,<span style="color: #000080;"> {</span>
   fontFamily<span style="color: #0000ff;">: 'Adelle Basic Rg'</span>,
   hover<span style="color: #0000ff;">:</span> <span style="color: #000080;">true</span>,
   hoverables<span style="color: #0000ff;">:</span> <span style="color: #000080;">{</span> li<span style="color: #0000ff;">:</span> <span style="color: #000080;">true }</span>,
   ignore<span style="color: #0000ff;">:</span> <span style="color: #000080;">{</span> ul<span style="color: #0000ff;">:</span> <span style="color: #000080;">true }</span>,
   textShadow<span style="color: #0000ff;">: '1px 1px #fff' </span><span style="color: #000080;">})</span>;</pre>
<h3>Everything explained</h3>
<ul>
<li>The <code>Cufon.replace()</code> function above uses the CSS <strong>child selector</strong> to target the top level list items in your main <code>&lt;ul&gt;</code>. <em></em></li>
<li>The <code>fontFamily</code> option tells Cufón which font to use. This is only required if you are using Cufón to replace more than one font.</li>
<li>By default, Cufón does not respect CSS hover properties, so we enable it by setting <code>hover</code> to true.</li>
<li>Without the <code>hoverables</code> option, the top level links will retain their hover styling after hovering over a submenu and then leaving.</li>
<li>The child selector alone is not enough; Cufón will replace <em>all </em>of your list items, so we tell it to <code>ignore</code> nested lists.</li>
<li>Finally, we add a little <code>textShadow</code>. We do this here because Cufón will not read it from our CSS.</li>
</ul>
<p>Remember that Cufón does not support the &#8220;blur&#8221; option of <code>text-shadow</code>, which means you&#8217;ll have to settle for relatively hard-looking shadows. In the code block above, I&#8217;ve only specified the X- and Y-offset and the shadow color.</p>
<p>This code has been tested in Firefox 4, IE 8, Chrome 10, and Safari 4.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/cufon-font-replacement-with-dropdown-menus/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Christmas Lights Photoshop Tutorial</title>
		<link>http://www.3roadsmedia.com/blog/christmas-lights-photoshop-tutorial/</link>
		<comments>http://www.3roadsmedia.com/blog/christmas-lights-photoshop-tutorial/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 22:18:48 +0000</pubDate>
		<dc:creator>Brennan</dc:creator>
				<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1512</guid>
		<description><![CDATA[As the holidays approach this year, try making your own gifts &#38; cards for people. To make it a little easier on you, we&#8217;ve created a helpful tutorial on how to make Christmas and Holiday lights in Photoshop, a perfect addition to any hand-made present. This tutorial is for beginner to intermediate Photoshop users. Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>As the holidays approach this year, try making your own gifts &amp; cards for people. To make it a little easier on you, we&#8217;ve created a helpful tutorial on how to make Christmas and Holiday lights in Photoshop, a perfect addition to any hand-made present.</p>
<p>This tutorial is for beginner to intermediate Photoshop users.<br />
<span id="more-1512"></span></p>
<h2>Let&#8217;s get right to it:</h2>
<p><strong>1.</strong> Open Photoshop and create a <strong>new document</strong> (File &gt; New). Make your document <strong>500px × 500px</strong>, 300 pixels/inch, RGB Color Mode. Click &#8220;OK.&#8221;</p>
<div id="attachment_1522" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb1.png"><img class="size-full wp-image-1522  " title="lightbulb1" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb1.png" alt="" width="480" height="367" /></a><p class="wp-caption-text">Create a new document 500 by 500 pixels</p></div>
<p><strong>2.</strong> Hit the &#8216;D&#8217; key to restore the default foreground and background colors. Double-click the &#8216;Background&#8217; layer and click &#8216;OK&#8217; to unlock it.</p>
<p><strong>3.</strong> With the <strong>Move Tool</strong> selected, hit <strong>Ctrl + T</strong> to <strong>free transform</strong> Layer 0. While the layer is in Free Transform mode, <strong>create 2 centered guides</strong> by clicking within the ruler and dragging to the center of your object.  Hit Enter to end/cancel the free transform. You should now have 2  centered guides, <strong>one vertical and one horizontal</strong> (hit Ctrl + : to turn on your guides).</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb2.png"><img class="size-full wp-image-1523  alignnone" title="lightbulb2" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb2.png" alt="" width="480" height="240" /></a></p>
<p><strong>4.</strong> Select the <strong>Ellipse Tool</strong>.</p>
<p><strong>5.</strong> Position your cursor in the center of your document. Click and hold  the mouse button to start your circle. AFTER you click, hit Shift + Alt,  then drag your mouse to create a perfect, centered circle. <strong>Make it about 170px × 170px.</strong></p>
<div id="attachment_1524" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb3.png"><img class="size-full wp-image-1524  " title="lightbulb3" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb3.png" alt="" width="480" height="491" /></a><p class="wp-caption-text">A perfect circle.</p></div>
<p><strong>6.</strong> Hold Alt, then click and drag your circle straight up to create a <strong>new, identical circle.</strong></p>
<div id="attachment_1528" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb4.png"><img class="size-full wp-image-1528  " title="lightbulb4" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb4.png" alt="" width="480" height="491" /></a><p class="wp-caption-text">Hold ALT and drag to duplicate your circle.</p></div>
<p><strong>7.</strong> With the new circle selected, hit <strong>Ctrl + T to &#8216;Free Transform&#8217;</strong> the circle. At the top of your screen, below the top menu, you will see options for transforming your object, specifically <strong>Width (W:) and Height (H:)</strong> with the Link symbol between them. Click the link symbol, then change Width to <strong>50%</strong> (Having width and height linked will automatically change width to 50% as well). Hit Enter to confirm the transformation.</p>
<div id="attachment_1530" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb5.png"><img class="size-full wp-image-1530  " title="lightbulb5" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb5.png" alt="" width="480" height="491" /></a><p class="wp-caption-text">The second circle, post transform</p></div>
<p><strong>8.</strong> Select the <strong>Pen Tool.</strong></p>
<p><strong>9.</strong> Click a point on the left edge of the original circle to create your  first point. Then make a point on the left edge of the top, small  circle.</p>
<div id="attachment_1531" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb6.png"><img class="size-full wp-image-1531  " title="lightbulb6" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb6.png" alt="" width="480" height="491" /></a><p class="wp-caption-text">Use the pen tool to connect your circles</p></div>
<p><strong>10.</strong> Create a 3rd point in the center of the top small circle (on or past the vertical axis/guide). Create a 4th point in the center of the bottom circle, then click back on to your original point to close the object (Your final shape should look like <strong>one half of the light bulb</strong>, a smooth connection between the 2 circles).</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb7.png"><img class="size-full wp-image-1533 alignnone" title="lightbulb7" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb7.png" alt="" width="480" height="491" /></a></p>
<p><strong>11.</strong> Select this new layer in your Layers Palette. Click and drag the layer onto the &#8216;New Layer&#8217; icon to <strong>create an identical layer</strong>.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb8.png"><img class="size-full wp-image-1534 aligncenter" title="lightbulb8" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb8.png" alt="" width="252" height="477" /></a></p>
<p><strong>12.</strong> Free Transform (Ctrl + T) your new layer. Click and drag the center axis icon onto the centered, vertical guide. Right-click (Macbook: Ctrl + Click) the object, and choose &#8216;Flip Horizontal&#8217; to <strong>flip your object across the vertical axis</strong>. Hit Enter to confirm the transformation. You now have a basic, symmetrical light bulb shape.</p>
<div id="attachment_1536" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb9.png"><img class="size-full wp-image-1536  " title="lightbulb9" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb9.png" alt="" width="480" height="491" /></a><p class="wp-caption-text">Our Christmas bulb, before electricity</p></div>
<p><strong>13.</strong> Select all 4 smart object layers (exclude the original background layer) and hit Ctrl + E (or &#8216;Layer &gt; Merge Layers&#8217;) to <strong>merge all 4 layers</strong>.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb10.png"><img class="size-full wp-image-1537 aligncenter" title="lightbulb10" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb10.png" alt="" width="254" height="181" /></a></p>
<p><strong>14.</strong> Double-click the layer within the Layer Palette to bring up the &#8216;Layer Style&#8217; dialogue box.</p>
<p><strong>15.</strong> On the left, select <strong>&#8216;Gradient Overlay.&#8217;</strong> Change &#8216;Style&#8217; from &#8216;Linear&#8217; to &#8216;Radial.&#8217; Deselect the &#8216;Align with Layer&#8217; Option.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb11.png"><img class="size-full wp-image-1538 alignnone" title="lightbulb11" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb11.png" alt="" width="480" height="276" /></a></p>
<p><strong>16.</strong> Click the colored gradient bar to bring up the &#8216;Gradient Editor.&#8217; Drag the far right, white color stop to Location: 80%.</p>
<p><strong>17.</strong> Double-click the white color stop to select a new color. Select a <strong>dark red</strong> (we used #550000). Click &#8216;OK.&#8217; Double-click the left, black color stop to select its new color &#8211; Select a <strong>bright red</strong> (we used #ff0000). Click &#8216;OK.&#8217; Click &#8216;OK&#8217; in the Gradient Editor.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb12.png"><img class="size-full wp-image-1539 alignnone" title="lightbulb12" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb12.png" alt="" width="480" height="291" /></a></p>
<p><strong>18.</strong> With the &#8216;Layer Style&#8217; dialogue box still up, select <strong>&#8216;Inner Glow&#8217;</strong> (See image below for final glow settings). Change Blend Mode to &#8216;Multiply.&#8217; Click the colored swatch to &#8216;select color of glow&#8217;. Select a medium red this time, #a00000, and click &#8216;OK&#8217;. Change the glow &#8216;Size&#8217; to 50px. Click &#8216;OK&#8217; to close the &#8216;Layer Style&#8217; dialogue box.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb13.png"><img class="size-full wp-image-1540 aligncenter" title="lightbulb13" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb13.png" alt="" width="324" height="389" /></a></p>
<p><strong>19.</strong> With your light bulb layer selected, Hit Ctrl + G to <strong>create a new group</strong>, then hit Ctrl + E to <strong>merge the group</strong>, flattening your light bulb&#8217;s effects.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb14.png"><img class="size-full wp-image-1541 alignnone" title="lightbulb14" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb14.png" alt="" width="480" height="488" /></a></p>
<p><strong>20.</strong> Double-click this flattened layer to again bring up the &#8216;Layer Style&#8217; dialogue box. <strong>Select &#8216;Gradient Overlay&#8217; again.</strong> This time, change Blend Mode to &#8216;Pin Light.&#8217; As before, change &#8216;Style&#8217; to &#8216;Radial&#8217; and deselect the &#8216;Align with Layer&#8217; option.</p>
<p><strong>21.</strong> Click the Gradient color bar to bring up the Gradient Editor. Select the left, black color stop and change it to white. Select the Opacity Stop above the right color stop, change its opacity to 0%, and change its location to 50%. Click &#8216;OK&#8217;.</p>
<p><strong>22.</strong> Change Opacity to 50%, and change Scale to 50% (See image below). Click &#8216;OK&#8217;.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb15.png"><img class="size-full wp-image-1543 aligncenter" title="lightbulb15" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb15.png" alt="" width="331" height="232" /></a></p>
<p><strong>23.</strong> Click and drag this layer onto the &#8216;New Layer&#8217; icon to <strong>duplicate the layer</strong>. With this new layer selected, hit Ctrl + T to Free Transform. Using the same controls as before, change <strong>Width to 80% and Height to 90%</strong>, then hit Enter to confirm.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb16.png"><img class="size-full wp-image-1544 aligncenter" title="lightbulb16" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb16.png" alt="" width="452" height="135" /></a></p>
<p><strong>24.</strong> Double-click this layer&#8217;s <strong>&#8216;Gradient Overlay&#8217;</strong> option to edit the Layer Style. Use the following settings:</p>
<ul>
<li>Blend Mode: Lighten</li>
<li>Opacity: 80%</li>
<li>Style: Linear</li>
<li>Angle: -17</li>
</ul>
<p>Click &#8216;OK&#8217;</p>
<p><strong>25.</strong> Change this layer&#8217;s <strong>Fill to 0%</strong>.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb17.png"><img class="size-full wp-image-1545 alignnone" title="lightbulb17" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb17.png" alt="" width="480" height="222" /></a></p>
<p><strong>26.</strong> Select your two light bulb layers, and hit Ctrl + G to group them. Name this group &#8216;Bulb&#8217;.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb18.png"><img class="size-full wp-image-1546 aligncenter" title="lightbulb18" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb18.png" alt="" width="252" height="140" /></a></p>
<p><strong>27.</strong> Create a new layer. Using the Rounded Rectangle tool (with a corner radius of 5px), <strong>create a rounded rectangle roughly 180px wide and 50px tall</strong>. Center it vertically, and position it just over the bottom of the bulb, as shown here:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb19.png"><img class="size-full wp-image-1547 alignnone" title="lightbulb19" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb19.png" alt="" width="480" height="488" /></a></p>
<p><strong>28.</strong> Double-click the layer, and select <strong>Gradient Overlay</strong> &#8211; this time, we&#8217;re only changing the color, everything else can stay. Change the left color stop to a dark green (#022700) and the right color stop to a pale, washed-out green (#46663a), then click &#8216;OK&#8217; twice to close the Layer Style box.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb20.png"><img class="size-full wp-image-1548 alignnone" title="lightbulb20" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb20.png" alt="" width="480" height="488" /></a></p>
<p><strong>29.</strong> Create another new layer. Using the Rounded Rectangle tool, <strong>create a rounded rectangle roughly 100px wide by 145px tall</strong>. Hit Ctrl + { to move the layer behind the top green piece.</p>
<p><strong>30.</strong> Hit Ctrl + T to enter the Free Transform mode, then right-click and choose <strong>&#8216;Perspective.&#8217;</strong> You want to make the top of the rectangle wider, so simply click and drag the top right anchor point to the right, until the shape looks the way you want. Hit Enter to confirm.</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb21.png"><img class="size-full wp-image-1549 alignnone" title="lightbulb21" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb21.png" alt="" width="480" height="488" /></a></p>
<p><strong>31.</strong> Double-click the layer, and add a <strong>Gradient Overlay</strong>. Change the right color stop to #021500, a very dark green. Change the left color stop to the same dark green from the top rectangle (#022700). Click &#8216;OK&#8217;.</p>
<p><strong>32.</strong> Select the two rectangle layers, hit Ctrl + G to group them and name the group &#8220;Base.&#8221;</p>
<p><em>Congratulations, you&#8217;ve made a cheery holiday light bulb!</em></p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb22.png"><img class="size-full wp-image-1550 alignnone" title="lightbulb22" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/12/lightbulb22.png" alt="" width="480" height="285" /></a></p>
<p>You can of course add more detail to the base, and change the hue of the bulb to create different colors. When using this light on a darker surface, feel free to add an Outer Glow to the bulb itself.</p>
<p>We hope you found this tutorial useful. Happy Holidays!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/christmas-lights-photoshop-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Separate Gradients for Screen Printing Using Halftones</title>
		<link>http://www.3roadsmedia.com/blog/how-to-separate-gradients-for-screen-printing-using-halftones/</link>
		<comments>http://www.3roadsmedia.com/blog/how-to-separate-gradients-for-screen-printing-using-halftones/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 03:55:17 +0000</pubDate>
		<dc:creator>Brennan</dc:creator>
				<category><![CDATA[Illustrator]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1413</guid>
		<description><![CDATA[Screen printing has become the modern go-to printing technique. But when your beautiful design includes gradients, preparing your artwork for print quickly becomes an unexpected nightmare. Don&#8217;t worry, we&#8217;re here to help. What you&#8217;ll need: The Illustrator File (CS4) Adobe Illustrator Adobe Photoshop A Brief Definition of Screen Printing Screen printing is a printing technique [...]]]></description>
			<content:encoded><![CDATA[<p>Screen printing has become the modern go-to printing technique. But when your beautiful design includes gradients, preparing your artwork for print quickly becomes an unexpected nightmare. Don&#8217;t worry, we&#8217;re here to help.</p>
<h2>What you&#8217;ll need:</h2>
<ul>
<li><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/halftone-gradient-tutorial.ai">The Illustrator File (CS4)</a></li>
<li>Adobe Illustrator</li>
<li>Adobe Photoshop</li>
</ul>
<p><span id="more-1413"></span></p>
<h2>A Brief Definition of Screen Printing</h2>
<p>Screen printing is a printing technique in which ink is pushed through a fine mesh screen, which has a stencil of your design.</p>
<ol>
<li>First, you coat the screen with a light-sensitive emulsion.</li>
<li>Then, you place your photo negative image on top of the emulsified screen. Your image is printed in pure black on a transparent surface, such as a piece of transparency paper, or vellum.</li>
<li>Expose the screen to a strong light source, ensuring that your image is between the light and the emulsion. The emulsion covered by your image remains unexposed, while the exposed emulsion dries.</li>
<li>Remove your image, and rinse out the screen. Like magic, the previously protected emulsion washes away, leaving a stencil.</li>
<li>Push your ink through the screen&#8230;</li>
<li>And now you have your print!</li>
</ol>
<div id="attachment_1430" class="wp-caption alignnone" style="width: 490px"><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/Screen-Print-Diagram.jpg" rel="post-image"><img class="size-full wp-image-1430 " title="Screen Print Diagram" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/Screen-Print-Diagram.jpg" alt="" width="480" height="366" /></a><p class="wp-caption-text">A visual representation of the screen printing process</p></div>
<p>Screen printing is a one-color process meaning you print every color separately using a separate screen. For example, if you want to print an image with dark red &amp; pink, you would print the dark red first (1), then print the pink (2) on top of that to create a final image (1+2):</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial1.png" rel="post-image"><img class="alignnone size-full wp-image-1416" title="sp_tutorial1" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial1.png" alt="" width="480" height="143" /></a></p>
<h2>The Problem with Gradients</h2>
<p>Gradients present an issue in Screen printing because of the screen burning process.</p>
<p>With digital printing, every color is printed simultaneously &amp; precisely with varying percentages of Cyan, Magenta, Yellow and Black. When you use a digital printer, your gradient is perfectly fine as rendered on the computer because digital printers can print gradients by merely fading out the amount of ink used:</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial2.jpg" rel="post-image"><img class="alignnone size-full wp-image-1419" title="sp_tutorial2" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial2.jpg" alt="" width="480" height="83" /></a></p>
<p>But when preparing your file for screen printing, it is essential to use halftones because you need a pure, solid color to block the light and burn your screen correctly.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial3.png" rel="post-image"><img class="alignnone size-full wp-image-1420" title="sp_tutorial3" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial3.png" alt="" width="480" height="83" /></a></p>
<p>Screens also vary by mesh: a higher mesh means a screen is more tightly woven, which allows for more detail but also allows less ink to pass through; a lower mesh is the opposite, more loosely woven allowing more ink to pass through to better print large areas of color. So you can create finer, smoother gradients by using a higher mesh screen.</p>
<h2>Halftones are the answer</h2>
<p>Changing your gradients into halftones allows you to create the visual appearance of a smooth blend but still block light properly. When done right, halftones are only visible at very close distances:</p>
<div id="attachment_1423" class="wp-caption alignnone" style="width: 490px"><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial4.png" rel="post-image"><img class="size-full wp-image-1423 " title="sp_tutorial4" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_tutorial4.png" alt="" width="480" height="244" /></a><p class="wp-caption-text">A close up showing halftones</p></div>
<h2>How to Separate Gradients Using Halftones</h2>
<p>Before starting the tutorial, here are a few important factors to keep in mind about your future designs:</p>
<ul>
<li>Just like other situations, if your original file is raster, create it at actual size.</li>
<li>How fine of a mesh will your screen printer be using? If your artwork is very detailed, this is a good thing to specify.</li>
<li>How many colors will you use? A ten-color design might look great, but often times clients will want a more affordable option &#8211; screen printers will charge more to print additional colors.</li>
<li>And of course, is your design best-suited for screen printing? Sometimes a certain design, like a photograph, just doesn&#8217;t work as a screen print. It&#8217;s okay, accept it and move on.</li>
</ul>
<p>This tutorial is geared towards beginner to intermediate screen printers/designers and people looking for a fairly simple, straight forward process without the need of additional programs or software. In this tutorial we will be preparing a vector rose graphic for a 3-color screen print. Let&#8217;s begin.</p>
<h3>Create Spot Colors</h3>
<p>We will first change each color into a &#8216;spot&#8217; color, so that it is no longer a CMYK mix, or Process color. This makes it easier to separate each color into it&#8217;s own layer to burn separate screens.</p>
<p><strong>1.</strong> Open the &#8216;halftone-gradient-tutorial.ai&#8217; file (Download above)</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot1.jpg" rel="post-image"><img class="alignnone size-full wp-image-1439" title="sp_screenshot1" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot1.jpg" alt="" width="480" height="300" /></a></p>
<p><strong>2.</strong> With the Selection Tool, select the rose fill, the blue to red gradient.</p>
<p><strong>3.</strong> Open up your Gradient window (Window &gt; Gradient) and select the left, cyan color stop.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot2.jpg" rel="post-image"><img class="alignnone size-full wp-image-1441" title="sp_screenshot2" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot2.jpg" alt="" width="480" height="232" /></a></p>
<p><strong>4. </strong>With the color stop highlighted, go to your Color window. Click and drag the cyan box into your Swatches window to create a new cyan swatch.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot3.png" rel="post-image"><img class="alignnone size-full wp-image-1442" title="sp_screenshot3" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot3.png" alt="" width="216" height="265" /></a></p>
<p><strong>5.</strong> Now select the right magenta color stop in your Gradient window.</p>
<p><strong>6.</strong> Your color window should now have a magenta box. As before, click and drag the box into your Swatches window to create a new magenta swatch.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot4.png" rel="post-image"><img class="alignnone size-full wp-image-1443" title="sp_screenshot4" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot4.png" alt="" width="215" height="133" /></a></p>
<p><strong>7.</strong> Deselect the rose.</p>
<p><strong>8.</strong> Double click your newly created cyan swatch.</p>
<p><strong>9.</strong> In the dialogue box, change Color Type from &#8216;Process Color&#8217; to &#8216;Spot Color&#8217; and click &#8216;OK&#8217;.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot5.png" rel="post-image"><img class="alignnone size-full wp-image-1444" title="sp_screenshot5" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot5.png" alt="" width="464" height="332" /></a></p>
<p><strong>10.</strong> Turn the magenta swatch into a Spot Color, using the same method.</p>
<p><strong>11.</strong> Reselect the rose.</p>
<p><strong>12.</strong> Click and drag the cyan spot color onto the left gradient swatch. Also replace the right color stop with the magenta spot color.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot6.png" rel="post-image"><img class="alignnone size-full wp-image-1445" title="sp_screenshot6" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot6.png" alt="" width="480" height="279" /></a></p>
<p><strong>13.</strong> Your rose gradient is now using both spot colors.</p>
<p><strong>14.</strong> Save your progress.</p>
<h3>Separate Your Colors</h3>
<p>We will now separate each color to print individually. <em>Although each color will save as black, remember that a black ink image will block light the best for screen printing. You choose the actual ink color for your image once you&#8217;re finally printing through the burned screen.</em></p>
<p><strong>1. </strong>Go to File &gt; Print&#8230;</p>
<p><strong>2. </strong>For &#8216;Printer:&#8217; choose &#8216;Adobe PostScript File&#8217; and leave &#8216;PPD:&#8217; as is.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot7.png" rel="post-image"><img class="alignnone size-full wp-image-1447" title="sp_screenshot7" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot7.png" alt="" width="480" height="433" /></a></p>
<p><strong>3. </strong>Select &#8216;Output&#8217; from the options on the left.</p>
<p><strong>4. </strong>For &#8216;Mode&#8217; choose &#8216;Separations (Host-Based)&#8217; (This could vary depending on your printer)</p>
<p><strong>5. </strong>You can leave Emulsion, Image and Printer Resolution to their default settings.</p>
<p><strong>6. </strong>In the Document Ink Options, turn off every ink other than the cyan spot color, by clicking the printer icons next to each ink. See screenshot below:</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot8.png" rel="post-image"><img class="alignnone size-full wp-image-1448" title="sp_screenshot8" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot8.png" alt="" width="480" height="432" /></a></p>
<p><strong>7. </strong>Click &#8216;Save&#8217; &#8211; Name the file &#8216;Cyan Spot Channel&#8217; and click &#8216;Save&#8217;</p>
<p><strong>8. </strong>Repeat this process to save a file for the Magenta Spot Channel, and lastly for Process Black &#8211; you should end up with 3 separate saved files. <em></em></p>
<p><em>Note: For future projects, be sure your artboard is the same size as your art, otherwise your Adobe PostScript File will be cropped.</em></p>
<h3>Create the Halftones</h3>
<p>We&#8217;re almost done, but we need to finish the process in Photoshop.</p>
<p><strong>1.</strong> While still in Illustrator, go to File &gt; Open to open one of your newly created PostScript files &#8211; I will use &#8216;Cyan Spot Channel&#8217; as the example. On Mac, you must first specify Adobe PostScript files to open in Illustrator.</p>
<p><strong>2. </strong>Select the black to white gradient with the Selection Tool.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot9.png" rel="post-image"><img class="alignnone size-full wp-image-1449" title="sp_screenshot9" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot9.png" alt="" width="480" height="362" /></a></p>
<p><strong>3.</strong> Copy your selection.</p>
<p><strong>4. </strong>Open Photoshop and create a new document. The settings should match that of your copied gradient, but just in case, the dimensions should be 2289px wide, 2269px tall, 300 ppi.</p>
<p><strong>5. </strong>For &#8216;Color Mode&#8217; choose Grayscale.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot10.png" rel="post-image"><img class="alignnone size-full wp-image-1450" title="sp_screenshot10" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot10.png" alt="" width="480" height="283" /></a></p>
<p><strong>6.</strong> Paste the object into your Photoshop document &#8211; Paste As: Pixels &#8211; Click &#8216;OK&#8217; &#8211; Hit Enter to commit to transform.</p>
<p><strong>7.</strong> Hit Control + L, or Command + L on Mac, to bring up the Levels dialogue box.</p>
<p><strong>8.</strong> Move the left black color stop to the beginning of the graph, around &#8217;23&#8242;. Click &#8216;OK&#8217;.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot11.png" rel="post-image"><img class="alignnone size-full wp-image-1451" title="sp_screenshot11" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot11.png" alt="" width="480" height="311" /></a></p>
<p><strong>9.</strong> Go to Image &gt; Mode &gt; Bitmap&#8230;</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot121.png" rel="post-image"><img class="alignnone size-full wp-image-1453" title="sp_screenshot12" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot121.png" alt="" width="480" height="196" /></a></p>
<p><strong>10.</strong> &#8216;Flatten Layers?&#8217; click &#8216;OK&#8217;</p>
<p><strong>11.</strong> Output: 300 ppi and for Method choose &#8216;Halftone Screen&#8217;. Click &#8216;OK&#8217;</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot13.png" rel="post-image"><img class="alignnone size-full wp-image-1454" title="sp_screenshot13" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot13.png" alt="" width="428" height="255" /></a></p>
<p><strong>12.</strong> You can leave Frequency and Angle at their defaults, but change Shape to &#8216;Round&#8217; &#8211; Click &#8216;OK&#8217;. Note: Changing certain Bitmap settings will help you achieve your desired result, based on the amount of detail you require.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot14.png" rel="post-image"><img class="alignnone size-full wp-image-1455" title="sp_screenshot14" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot14.png" alt="" width="437" height="203" /></a></p>
<p><strong>13.</strong> Go to File &gt; Save As and save as whatever file type your printer needs &#8211; PDF&#8217;s are the most widely accepted format.</p>
<p><strong>14.</strong> Simply repeat this last set of steps for both your other colors (in this case, Magenta and Black), and your files are ready to go! <strong>Note: You should make each file a different Angle for best results.</strong></p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot15.png" rel="post-image"><img class="alignnone size-full wp-image-1456" title="sp_screenshot15" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/11/sp_screenshot15.png" alt="" width="480" height="300" /></a></p>
<p>A zoomed in shot of the final screen-ready image. When zoomed in extremely close, the image will appear pixelated, but at actual print size, it works great. Again, you can also toy around with the Bitmap settings to achieve your ideal results.</p>
<p>If you have any comments, questions, or feedback, we would love to hear from you. Also feel free to share any tips or other strategies as to how to go about the gradient halftone separation process. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/how-to-separate-gradients-for-screen-printing-using-halftones/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>ExpressionEngine with Structure and Categories</title>
		<link>http://www.3roadsmedia.com/blog/expressionengine-with-structure-and-categories/</link>
		<comments>http://www.3roadsmedia.com/blog/expressionengine-with-structure-and-categories/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 20:03:45 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Expression Engine]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1377</guid>
		<description><![CDATA[While Structure is great, its strict URL requirements make it difficult to rely on dynamic URL segments. This can make it a real head-scratcher to use categories with Structure. Luckily, you&#8217;ve just stumbled across a tutorial that will show you how to get ExpressionEngine, Structure, and categories working together. What you&#8217;ll need ExpressionEngine 2.0 Structure [...]]]></description>
			<content:encoded><![CDATA[<p>While Structure is great, its strict URL requirements make it difficult to rely on dynamic URL segments. <strong>This can make it a real head-scratcher to use categories with Structure. </strong>Luckily, you&#8217;ve just stumbled across a tutorial that will show you how to get ExpressionEngine, Structure, and categories working together.</p>
<h2>What you&#8217;ll need</h2>
<ul>
<li><a href="https://secure.expressionengine.com/">ExpressionEngine 2.0</a></li>
<li><a href="http://buildwithstructure.com/">Structure</a></li>
<li><a href="http://github.com/averyvery/Freebie">Freebie</a></li>
</ul>
<p><strong>This tutorial works for EE 2.0 users only.</strong> If you&#8217;re using EE 1.6.x, you may have some luck with <a href="http://github.com/newism/nsm.safe_segments.ee_addon">NSM Safe Segments</a>. This extension is an older, less feature-rich version of Freebie. It&#8217;s much less effective because it does not allow you to specify a &#8220;break on&#8221; segment – that is, a word in the URL that tells EE to &#8220;stop looking at the URL here and ignore everything after this word.&#8221; As you&#8217;ll see in a bit, this is vital to get categories to work with Structure.<br />
<span id="more-1377"></span></p>
<h2>The problem with Structure</h2>
<p>It&#8217;s more of an inherent limitation, really, but the bottom line is that <strong>Structure will only load a URL if one has been defined for it. </strong>This means that unless you want to create a new Structure page for each of your categories, you&#8217;ll need to be creative.</p>
<p>Rather than explain the problem – which you likely already understand – I&#8217;ll jump right into the solution.</p>
<h2>The solution, clearly explained</h2>
<p>This tutorial is based on an actual situation we encountered that required the use of categories within Structure. Our client wanted a section in the website to display their case studies. Since each case study was focused in a certain area of the globe, we decided to categorize each study by location (Africa, Middle East, etc.).</p>
<p>Here are the basic steps we followed:</p>
<ol>
<li>Create a &#8220;Case Studies&#8221; landing page, which has a list of links to each category</li>
<li>Create a channel to hold the case studies, then assign this as a &#8220;Listing Channel&#8221; within Structure</li>
<li>Create a category group and assign it to the case studies channel</li>
<li>Publish and categorize some case studies</li>
<li>Configure Freebie to ignore certain pieces of the URL</li>
<li>Build templates to display content</li>
</ol>
<h3>1. Create a landing page for your categories</h3>
<p>This part is easy. Go into Structure and create a new page. We called ours &#8220;Studies&#8221; and made it a main page (that is, it has no parent page).</p>
<div id="attachment_1385" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_page.png"><img class="size-full wp-image-1385  " title="Our new landing page" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_page.png" alt="" width="480" height="99" /></a><p class="wp-caption-text">How our new landing page appears in the Structure page list</p></div>
<h3>2. Create a channel for the case studies and make it a Structure listing</h3>
<p>Go to Admin › Channel Administration › Channels and create a new channel (ours is called &#8220;study&#8221;):</p>
<div id="attachment_1386" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_channel.png"><img class="size-full wp-image-1386  " title="Our new case studies channel" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_channel.png" alt="" width="480" height="50" /></a><p class="wp-caption-text">Our new case studies channel as it appears in the CP</p></div>
<p>The next step is associating this channel with the landing page we created in step #1. Structure supports something called &#8220;Listings,&#8221; which is a way to associate a channel with a Structure page. You can read more about them in <a href="http://buildwithstructure.com/documentation/page_types_whats_the_difference_between_a_page_listing_and_asset/">Structure&#8217;s documentation</a>.</p>
<p>To create a listing and assign it to a page:</p>
<p><strong>1.</strong> Go to Add-Ons › Modules › Structure and click the &#8220;Channel Settings&#8221; button</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step1.png"><img class="alignnone size-full wp-image-1388" title="Step 1: Click &quot;Channel Settings&quot;" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step1.png" alt="" width="480" height="199" /></a></p>
<p><strong>2.</strong> Find the &#8220;Study&#8221; channel we just created and select &#8220;Listing&#8221; for its type</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step2.png"><img class="alignnone size-full wp-image-1389" title="Step 2: Make the new channel a listing" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step2.png" alt="" width="480" height="99" /></a></p>
<p><strong>3.</strong> Go back to your main Structure page listing and click on the &#8220;Studies&#8221; page you created in step #1</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step3.png"><img class="alignnone size-full wp-image-1393" title="Step 3: Go back to the page we just created" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step3.png" alt="" width="480" height="99" /></a></p>
<p><strong>4.</strong> From the edit screen, click the &#8220;Structure&#8221; tab, then choose the &#8220;Study&#8221; channel from the &#8220;Listing channel&#8221; dropdown:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step4.png"><img class="alignnone size-full wp-image-1392" title="Step 4: Assign the listing to the page" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step4.png" alt="" width="480" height="310" /></a></p>
<p><strong>5.</strong> Click &#8220;Submit&#8221; and return to the Structure page listing. You should now see an &#8220;Entries: Add/Edit&#8221; option near your Studies page:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step5.png"><img class="alignnone size-full wp-image-1394" title="Step 5: If all is well, you'll see this" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_list_step5.png" alt="" width="480" height="99" /></a></p>
<p>Now, whenever you add a case study, it will be associated with the Studies page.</p>
<h3>3. Create a category group</h3>
<p>We created a category group called &#8220;Study Regions&#8221; and assigned the following categories to it:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_cats.png"><img class="alignnone size-full wp-image-1395" title="Our categories" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_cats.png" alt="" width="480" height="267" /></a></p>
<p>Be sure to assign your category group to the &#8220;Study&#8221; channel.</p>
<h3>4. Publish and categorize some channel entries</h3>
<p>Go nuts and add some entries to your new channel, making sure to categorize all of them. We&#8217;ll use these entries to test the templates we&#8217;re about to make.</p>
<h3>5. Configure Freebie</h3>
<p>Freebie is a really neat extension that allows you to specify URL segments that EE should ignore. These segments aren&#8217;t parsed by EE (and hence are also ignored by Structure), but they <em>are </em>parsed by Freebie, which means you still have access to all of your URL segments.</p>
<p>One common reason to use this extension is to display a success message (e.g., on the submission of a contact form). Rather than direct people to a separate &#8220;thank you&#8221; page, you might just want to show a success message on the same page. Your URL might look something like:</p>
<pre>www.mydomain.com/contact/success</pre>
<p>And your template might have something like:</p>
<pre>{if segment_2 == "success"}
   display a success message
{if:else}
   display the contact form
{/if}</pre>
<p>In this scenario, if you don&#8217;t have a Structure page with the URL <strong>contact/success</strong>, you&#8217;ll get a 404.</p>
<p>With Freebie, you can specify &#8220;success&#8221; as a URL segment to ignore. You would then change your template to:</p>
<pre>{if freebie_2 == "success"}
   display a success message
{if:else}
   display the contact form
{/if}</pre>
<p>Now, you don&#8217;t need to create a separate Structure page to display the success message.</p>
<h3>That&#8217;s great, but so what?</h3>
<p>The real power of Freebie comes when you specify a &#8220;breaking segment.&#8221; This is a word in the URL after which nothing will be parsed by EE. For instance, the following URL will generate a 404 in Structure (unless you have a page with category/africa as its URL):</p>
<pre>www.mydomain.com/studies/category/africa</pre>
<p>However, if you specify &#8220;studies&#8221; as a breaking segment, the following <em>will not </em>generate 404s in Structure:</p>
<pre>www.mydomain.com/studies/category/africa
www.mydomain.com/studies/category/africa/zimbabwe
www.mydomain.com/studies/category/north-america/us/colorado</pre>
<p>What <em>does </em>show? Whatever template you specified for the &#8220;studies&#8221; page – even if it looks ugly <img src='http://www.3roadsmedia.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Without this ability to ignore everything <em>after </em>&#8220;studies&#8221;, you would have to create a Structure page for <em>every single category and subcategory </em>you want to display. Clearly, this is an unrealistic thing to do, or to ask a client to do.</p>
<h3>How we configured Freebie</h3>
<p>&#8220;Configure&#8221; is a strong word. All you have to do is specify a breaking segment; in our example, this is <strong>studies</strong>, since we wanted the URL structure to look like this:</p>
<ul>
<li>Studies (landing page; URL: /studies)
<ul>
<li>Middle East (category page; URL: /studies/middle-east)</li>
<li>China (category page; URL: /studies/china)
<ul>
<li>Petroleum Exploration in South China (case study page; URL: /studies/china/petroleum-exploration&#8230;)</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>Our Freebie settings page therefore looks like this (Add-Ons › Extensions › Freebie):</p>
<div id="attachment_1396" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_freebie.png"><img class="size-full wp-image-1396 " title="Our breaking URL segment, as specified in Freebie settings" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_freebie.png" alt="" width="480" height="238" /></a><p class="wp-caption-text">The Freebie settings page</p></div>
<h3>6. Build your templates</h3>
<p>Once everything is set up, the final step is to build the templates that will display your categorized content.</p>
<p>I saved the code below in a template called &#8220;categorized&#8221; and placed it in my &#8220;site&#8221; template group (so the path to it is <strong>site/categorized</strong>).</p>
<h4>The Sidebar</h4>
<p>First of all, let&#8217;s get our sidebar going. It will display a list of all our categories, as well as assign a class of &#8220;here&#8221; to the currently viewed category. Here&#8217;s the code:</p>
<pre><span style="color: #000080;">&lt;div id="</span><span style="color: #0000ff;">sidebar</span><span style="color: #000080;">"&gt;
   </span><span style="color: #000080;">&lt;h3&gt;</span>Studies (By Region)<span style="color: #000080;">&lt;/h3&gt;
   </span><span style="color: #000080;">&lt;ul&gt;</span>
      <span style="color: #999999;">&lt;!-- show a list of all categories assigned to the "study" channel --&gt;
      </span>{exp:channel:category_archive channel="study" show_empty="no" style="linear"}
         {categories}
            <span style="color: #000080;">&lt;li</span>{if freebie_2 == category_url_title} <span style="color: #000080;">class="</span><span style="color: #0000ff;">here</span><span style="color: #000080;">"</span>{/if}&gt;<span style="color: #008000;">&lt;a href</span><span style="color: #000080;">="</span><span style="color: #0000ff;">{homepage}/studies/{category_url_title}</span><span style="color: #000080;">"</span><span style="color: #008000;">&gt;</span>{category_name}<span style="color: #008000;">&lt;/a&gt;</span><span style="color: #000080;">&lt;/li&gt;
         </span>{/categories}
      {/exp:channel:category_archive}
   <span style="color: #000080;">&lt;/ul&gt;
&lt;/div&gt;</span> <span style="color: #999999;">&lt;!-- end sidebar --&gt;
</span><span style="color: #999999;"> </span></pre>
<h4>The Main Content</h4>
<p>Next, I&#8217;m going to use some PHP to extract the category URL title from the page URL. <em>(<strong>Note: </strong>Read on for a non PHP solution.) </em>We&#8217;ll use this to get the category name and ID, which are used throughout the template.</p>
<p>If you don&#8217;t like enabling PHP in your templates, you might have some luck with the <a href="http://expressionengine.com/archived_forums/viewthread/80262/">Category ID plugin</a>, though frankly I don&#8217;t think it&#8217;s worth installing plugins or extensions to do something this simple.</p>
<p><strong> </strong>Be sure to set PHP parsing to <strong>input </strong>on your template, or none of this will work <img src='http://www.3roadsmedia.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Place this PHP at the beginning of your template:</p>
<pre><span style="color: #ff0000;">&lt;?php</span>
<span style="color: #ff9900;">   // retrieve category URL title from page URL</span>
   $url <span style="color: #000080;">=</span> <span style="color: #3366ff;">$_SERVER</span>[<span style="color: #ff0000;">'REQUEST_URI'</span>];
   $category_url <span style="color: #000080;">=</span> <span style="color: #0000ff;">explode(</span><span style="color: #ff0000;">'/'</span>, $url<span style="color: #0000ff;">)</span>;
   <span style="color: #008000;">if</span>(<span style="color: #0000ff;">!empty</span>($category_url[<span style="color: #ff0000;">5</span>])) <span style="color: #000080;">{</span> $category_url <span style="color: #000080;">=</span> $category_url[<span style="color: #ff0000;">5</span>]; <span style="color: #000080;">}</span>

<span style="color: #ff9900;">   // use category URL to look up category ID and name</span>
   $query <span style="color: #000080;">=</span> <span style="color: #0000ff;">mysql_query(</span><span style="color: #ff0000;">"SELECT cat_id, cat_name FROM exp_categories WHERE cat_url_title = '$category_url'"</span><span style="color: #0000ff;">)</span>;
   <span style="color: #008000;">while</span>($row <span style="color: #000080;">=</span> <span style="color: #0000ff;">mysql_fetch_assoc(</span>$query<span style="color: #0000ff;">))</span> {
      $category_id <span style="color: #000080;">=</span> $row[<span style="color: #ff0000;">'cat_id'</span>];
      $category_name <span style="color: #000080;">=</span> $row[<span style="color: #ff0000;">'cat_name'</span>];
   }
<span style="color: #ff0000;">?&gt;</span></pre>
<p><strong>Note: </strong>On line 5, you may have to change the number 5 to something else, depending on your URL structure. Test to make sure you are grabbing the category from the URL.</p>
<p>Somewhere after this, add these lines, which will let you reference your PHP variables with EE syntax:</p>
<pre>{preload_replace:categoree="<span style="color: #ff0000;">&lt;?php</span> <span style="color: #0000ff;">echo </span>$category_name; <span style="color: #ff0000;">?&gt;</span>"}
{preload_replace:categoree_id="<span style="color: #ff0000;">&lt;?php</span> <span style="color: #0000ff;">echo </span>$category_id; <span style="color: #ff0000;">?&gt;</span>"}</pre>
<p><em><strong>Update: </strong>Grabbing the category ID without using PHP.</em></p>
<p>I haven&#8217;t yet had the time to test out this suggestion from Steven Hambleton, who in <a href="http://www.3roadsmedia.com/wordpress/expressionengine-with-structure-and-categories/#comment-330">his comment</a> to this post recommended using the following to grab the category ID:</p>
<pre>{exp:freebie:category_id segment="x"}</pre>
<p>Set <em>x </em>to the segment number that contains your category URL title (e.g., segment=&#8221;2&#8243;).</p>
<p>You&#8217;ll need to install the Freebie plugin (available with the extension) to have access to this code snippet. If you go this route, simply omit the PHP and {preload_replace} lines from above, and place the immediately preceding bit of code wherever you need the category ID to appear. Thanks, Steven.</p>
<p>Finally, paste the following code where you&#8217;d like your main content to appear:</p>
<pre>&lt;h1&gt;Studies&lt;/h1&gt;

<span style="color: #000080;">&lt;div id="</span><span style="color: #0000ff;">content</span><span style="color: #000080;">"&gt;</span>
   <span style="color: #999999;">&lt;!-- freebie_2 is only empty when viewing the main studies page --&gt;</span>
   {if freebie_2 == ""}
      <span style="color: #000080;">&lt;h2&gt;</span>Studies<span style="color: #000080;">&lt;/h2&gt;</span>
      <span style="color: #000080;">&lt;p&gt;</span>Content for the main studies page goes here...<span style="color: #000080;">&lt;/p&gt;</span>
   <span style="color: #999999;">&lt;!-- freebie_3 is only non-empty when viewing a study in detail --&gt;</span>
   {if:elseif freebie_3 != ""}
      {exp:channel:entries channel="study" dynamic="no" url_title="{freebie_3}"}
         <span style="color: #000080;">&lt;h2&gt;</span>{title}<span style="color: #000080;">&lt;/h2&gt;</span>
         {your_custom_field}
      {/exp:channel:entries}
   <span style="color: #999999;">&lt;!-- if neither of the above is true, we must be viewing a category list of studies --&gt;</span>
   {if:else}
      <span style="color: #000080;">&lt;h2&gt;</span>Studies in {categoree}<span style="color: #000080;">&lt;/h2&gt;</span>
      <span style="color: #000080;">&lt;ul id="</span><span style="color: #0000ff;">studies</span><span style="color: #000080;">"&gt;</span>
         {exp:channel:entries channel="study" category="{categoree_id}" dynamic="no" orderby="title" sort="asc"}
            <span style="color: #000080;">&lt;li&gt;</span>
               <span style="color: #008000;">&lt;a href=</span><span style="color: #0000ff;">"{path='studies'}/{freebie_2}/{url_title}"</span><span style="color: #008000;">&gt;</span>{title}<span style="color: #008000;">&lt;/a&gt;</span>
               <span style="color: #000080;">&lt;em&gt;</span>{entry_date format="%F %Y"}<span style="color: #000080;">&lt;/em&gt;</span>
            <span style="color: #000080;">&lt;/li&gt;</span>
         {/exp:channel:entries}
      <span style="color: #000080;">&lt;/ul&gt;</span>
   {/if}
<span style="color: #000080;">&lt;/div&gt;</span> <span style="color: #999999;">&lt;!-- end content --&gt;</span></pre>
<h3>Understanding the code</h3>
<p>Before trying to get this code to work, make sure your URL structure is like this:</p>
<pre>http://www.example.com/studies/[category-url-title]/[entry-url-title-in-study-channel]</pre>
<p>If it&#8217;s not, adjust your template code accordingly. For example, in the URL above, freebie_2 corresponds to the <strong>category-url-title</strong> segment.</p>
<p>The code above is just examining the URL of the page. If freebie_2 is empty, you must be looking at the main studies page. If freebie_3 is empty <em>and </em>freebie_2 is not, you must be looking at a list of studies in a given category. Finally, if freebie_3 is <em>not </em>empty, you must be looking at a specific study.</p>
<p>If you have trouble with this code, feel free to post in the comments.</p>
<h2>One last thing</h2>
<p>Once you&#8217;ve coded your template, be sure to assign it to the &#8220;Studies&#8221; page you created in step #1 above:</p>
<div id="attachment_1400" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_assign.png"><img class="size-full wp-image-1400  " title="Assigning the template to the landing page" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/10/structure_assign.png" alt="" width="480" height="313" /></a><p class="wp-caption-text">Be sure you assign your freshly minted template to the page you created!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/expressionengine-with-structure-and-categories/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>How to Design for Letterpress</title>
		<link>http://www.3roadsmedia.com/blog/how-to-design-for-letterpress/</link>
		<comments>http://www.3roadsmedia.com/blog/how-to-design-for-letterpress/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 05:15:03 +0000</pubDate>
		<dc:creator>Brennan</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1190</guid>
		<description><![CDATA[Letterpress can push your design to the next level, but before letting your imagination soar, it is important to know the limits and possibilities of letterpress printing. Here are some helpful tips on how to design for Letterpress. 1. Know your medium Letterpress is a wonderful, time-tested process with unique qualities. Before even beginning your [...]]]></description>
			<content:encoded><![CDATA[<p>Letterpress can push your design to the next level, but before letting your imagination soar, it is important to know the limits and possibilities of letterpress printing. Here are some helpful tips on how to design for Letterpress.</p>
<h3>1. Know your medium</h3>
<p>Letterpress is a wonderful, time-tested process with unique qualities. Before even beginning your design, there are a few things to keep in mind about how Letterpress works.</p>
<h4>Letterpress is a spot color printing process</h4>
<p>When designing for Letterpress, it is important to remember that you&#8217;re dealing with a spot color printing process, and not the 4 color (CMYK) process. Where the 4 color process matches your on-screen colors by combining percentages of Cyan, Magenta, Yellow, and Black, a spot color process is very specific, <strong>using pure color rather than a mixture of CMYK</strong>. It is very important to reference your spot colors in person, and not simply rely on the on-screen rendition, as this can be vastly different from the actual Pantone color. Pick your colors in person using PMS, or the Pantone Matching System, then use those specific colors in your design (This post is written for Adobe Illustrator, but Photoshop and InDesign also contain Pantone swatches).</p>
<h4>Letterpress inks are translucent and will overlap</h4>
<p>Letterpress inks are thinned out and translucent to best work with the equipment. What does this mean for your design? If you have overlapping elements, the <strong>colors may blend</strong> unfavorably once printed. Do not overlay objects and design elements unless you want their colors to blend (you may preview this effect by switching transparency mode to &#8220;Multiply&#8221;). Of course, you can certainly use this feature to your advantage to achieve new colors without paying for additional inks.<br />
<span id="more-1190"></span></p>
<h4>Every color is printed separately</h4>
<p>This might already be apparent based on the previous Letterpress qualities, but every color in your design will be printed separately, and you will need to separate these colors for your printer. In Illustrator, it is easy to put each color on its own layer (described later in this post). The image below shows one color of our 3 color business cards, separated into its own layer:<a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards_setup.jpg"><img class="alignnone size-full wp-image-1269" title="3 Roads Media Business Card, First Color" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards-600x400_setup.jpg" alt="" width="480" height="320" /></a><br />
<em>Note that photographs, full-color imagery and gradients will not print well unless you know how to separate your colors (using techniques like halftones).</em></p>
<h4>Letterpress literally &#8216;presses&#8217; your imagery</h4>
<p><strong>Letterpress always makes an </strong><em><strong>impression</strong></em><strong>.</strong> When you send a printer your separated design, every layer/color is etched onto its own metal plate. This metal plate is then coated with your specified spot color and pressed onto the paper to apply the ink, creating an impression in the process. A light impression is called a &#8220;kiss.&#8221; A deep, noticeable impression is called a &#8220;bite.&#8221; For our business cards, I requested a &#8220;bite&#8221; on the front and a &#8220;kiss&#8221; on the back (putting a deep impression/bite on both sides of your design will show through to the other side).</p>
<h3>2. Create your design accordingly</h3>
<p>Now that you know more about what Letterpress can offer, you can begin developing your design. I used and recommend Illustrator, as it provides crisp designs that are easily translated to this printing technique. A few tips for your design:</p>
<ul>
<li><strong>Sketch it out first.</strong> This is important for any design, but especially a project as costly as Letterpress. You want to ensure you are completely satisfied with your design before investing in this technique.</li>
<li><strong>Keep Letterpress constraints in mind.</strong> Do not use full-color images, extremely small type, or razor thin strokes. Use techniques like halftones and tints with purpose, and keep in mind that they might not always show up as they would with an offset press.</li>
<li><strong>Utilize the benefits of Letterpress</strong>, such as a kiss/bite or by taking advantage of translucent inks to create a third color. You can also get fancy with custom die-cuts (notice the 3-corner die cut on my design below).</li>
<li><strong>Choose your colors wisely.</strong> Color can be a great asset to your design, if utilized properly, and remember to use spot colors, not CMYK.</li>
</ul>
<p>Here is the finalized mock-up of my design:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/Card-Mockup.jpg"><img class="alignnone size-full wp-image-1285" title="3 Roads Media Business Card Mock-Up" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/Card-Mockup.jpg" alt="" width="480" height="144" /></a></p>
<h3>3. Prepare your design for print</h3>
<p>Printers will ask for your files in whatever best fits their work flow and setup. With that in mind, here are some general file preparation tasks that should make your printer&#8217;s life easier:</p>
<h4>Separate your colors</h4>
<p>Unless you&#8217;re paying a fee to have this done for you, you will need to separate your colors before sending your file to print. <strong>To separate your colors in Adobe Illustrator:</strong></p>
<ol>
<li>First be sure that your artwork is all set. Save this editable art file in case you want to make changes later on.</li>
<li>Once you&#8217;ve saved, choose &#8220;Save As&#8221; and name it something straight forward, like &#8220;Business Card Front.&#8221;</li>
<li>Group your objects together (Object &gt; Group). In my case, I grouped all of the shapes and text.</li>
<li>Outline any live text (Type &gt; Create Outlines) and then expand any stroked objects (Object &gt; Expand).</li>
<li>With your group selected, open your Pathfinder window (Window &gt; Pathfinder) and click the &#8220;Merge&#8221; button under &#8220;Pathfinders.&#8221; This will ensure that nothing is accidentally overlapping.</li>
<li>At this point, all of your colors should be on the same layer, everything grouped and merged into one object.</li>
<li>Use your Direct Selection Tool and select one of your colored objects.</li>
<li>In your top menu bar, click &#8220;Select &gt; Same &gt; Fill Color.&#8221; This will select every object with that same spot color.</li>
<li>Without deselecting this color group, create a new layer (Layers window &gt; Create New Layer).</li>
<li>Move your selection to the new layer &#8211; Edit &gt; Cut &gt; Select your new layer in the layers palette &gt; Edit &gt; <strong>Paste in Front</strong> (you must choose &#8220;Paste in Front&#8221; to keep everything aligned).</li>
<li>Once your selection is on your new layer, regroup it (Object &gt; Group). This layer should now have every object from the one selected spot color.</li>
<li>Repeat this process for remaining spot colors.</li>
<li>Once every color is on its own separate layer, save the file. <em>If you have a double-sided design, save each side as its own separate file.</em></li>
</ol>
<p>In the example below, the gold objects are on layer one, the red &#8220;web&#8221; bubble is on layer 2, and the deep red &#8220;creative strategy&#8221; bubble in on layer 3:</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards_grid.jpg"><img class="alignnone size-full wp-image-1265" title="3roads cards 600x400_grid" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards-600x400_grid.jpg" alt="" width="480" height="320" /></a></p>
<h4>Pull your bleeds</h4>
<p>If you want your design to go right to the edge, you will need it to &#8220;bleed.&#8221; This simply means expanding the color/imagery past the trim mark. A good rule of thumb is to expand your bleeds at least <strong>1/8&#8243;</strong> past your trim marks. For example, if your finished business card is going to be 3.5&#8243; x 2&#8243;, your design should be at least 3.75&#8243; x 2.25&#8243; with bleeds included. <em>Note: You should get specifics from your printer before finalizing your file, to ensure your file meets their specifications.</em></p>
<h4>Utilize your given space</h4>
<p>When printing mass quantities, it is usually cost effective to print more than one design at a time. In my case, I placed my business card design 4 times on the same file, to decrease press runs and therefore, decrease cost. <strong>By printing 4 cards at once, space, time and resources are used efficiently.</strong> Here is the design after the first color was pressed (notice how different this printed gold color is compared to my original on-screen mock-ups):</p>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards_1color.jpg"><img class="alignnone size-full wp-image-1262" title="3roads cards 600x400_1color" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards-600x400_1color.jpg" alt="" width="480" height="320" /></a></p>
<h3>4. Double check, then send to print</h3>
<p>Once you&#8217;ve finished your design, separated your colors, checked your bleeds and margins, and specified any final details like foil stamping or die-cuts, then you are ready to roll. Save your files in an acceptable format, send them off and wait to see how your freshly Letterpressed design comes out! <em>Most printers will also bring you in to do press checks, but if not,  always request press checks for Letterpress, to ensure that what&#8217;s being printed is exactly how you want it before the entire order goes through.</em></p>
<h4>Our newly printed examples</h4>
<p>Check out some photos of the recently finished <a href="http://www.3roadsmedia.com/">3 Roads Media</a> business cards below. Special thanks to Denver&#8217;s own <a href="http://www.vintagepressworks.com/">Foils + Dies</a> for the beautiful finished products.</p>
<div id="attachment_1266" class="wp-caption alignnone" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards_layout.jpg"><img class="size-full wp-image-1266 " title="3roads cards 600x400_layout" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards-600x400_layout.jpg" alt="" width="480" height="320" /></a><p class="wp-caption-text">The final product</p></div>
<h4>Design details:</h4>
<ul>
<li>Created using Adobe Illustrator CS5</li>
<li>3-color wrap-around design</li>
<li>3-corner die cut</li>
<li>Deep &#8220;bite&#8221; for front design/light &#8220;kiss&#8221; for back design</li>
<li>Font: Rockwell</li>
</ul>
<p><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards_zoom.jpg"><img class="alignnone size-full wp-image-1271" title="3roads cards 600x400_zoom" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/08/3roads-cards-600x400_zoom.jpg" alt="" width="480" height="320" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/how-to-design-for-letterpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multilevel dropdown category navigation in ExpressionEngine</title>
		<link>http://www.3roadsmedia.com/blog/multilevel-dropdown-category-navigation-in-expressionengine/</link>
		<comments>http://www.3roadsmedia.com/blog/multilevel-dropdown-category-navigation-in-expressionengine/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 21:54:50 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Expression Engine]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=1099</guid>
		<description><![CDATA[If you&#8217;ve ever wanted to create dropdown, category-based navigation in your ExpressionEngine website, you&#8217;ve probably also wanted to punch a hole in your desk. It&#8217;s not easy. Or is it? In this tutorial, I&#8217;ll show you how. Requirements To follow along in this tutorial, you&#8217;ll need: An ExpressionEngine website running EE 1.6.x The Subcategories plugin [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever wanted to create dropdown, category-based navigation in your ExpressionEngine website, you&#8217;ve probably also wanted to punch a hole in your desk. It&#8217;s not easy. Or is it? In this tutorial, I&#8217;ll show you how.</p>
<h2>Requirements</h2>
<p>To follow along in this tutorial, you&#8217;ll need:</p>
<ul>
<li>An ExpressionEngine website running EE 1.6.x</li>
<li>The Subcategories plugin</li>
<li>To use category URL titles in your links, <strong>not </strong>category IDs</li>
</ul>
<p>The Subcategories plugin is available for download on <a href="http://expressionengine.com/forums/viewthread/27220/">this thread</a> in the EE forums; however, since it&#8217;s not clear which version to grab, and since there was a minor bug in the code, I&#8217;ve made a corrected version available for direct download <a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/07/pi.subcategories.txt">right here</a>.</p>
<p>Grab the plugin, save it as <strong>pi.subcategories.php</strong>, and upload it to your <strong>system/plugins </strong>directory.</p>
<h2>Live Demo</h2>
<p>If you&#8217;re the visual type (like I am) you probably need to <a href="http://www.3roadsmedia.com/sandbox/index.php/site/">see the menus in action</a>. The demo is pulling from a live EE install on our web server. It may also help to <a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/07/ee_cat_structure.png">see a screenshot of the category heirarchy</a>.<br />
<span id="more-1099"></span></p>
<h2>Template Structure</h2>
<p>Once you&#8217;ve uploaded the plugin file, you&#8217;ll need to create a few templates:</p>
<ol>
<li>embeds/navigation</li>
<li>embeds/subcategories</li>
<li>embeds/sub_subcategories</li>
<li>an additional embed for each additional level of subcategories (if you desire more)</li>
</ol>
<p>For the visuals, here is <a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2010/07/ee_template_page.png">a screenshot of my templates page</a>.</p>
<p>The <strong>embeds/navigation </strong>template controls your main, top-level navigation. Embedding this template as I have done is optional; you can also leave your main navigation code in your header template (or wherever it normally appears).</p>
<p>The <strong>embeds/subcategories </strong>template is only called if a top-level category has any subcategories. It displays a list of, well&#8230;subcategories.</p>
<p>The <strong>embeds/sub_subcategories </strong>template is only called if a subcategory has any subcategories.</p>
<p>You can create as many levels of dropdowns/flyouts as you want by replicating the <strong>embeds/subcategories </strong>template and naming it something else (like embeds/sub_sub_subcategories).</p>
<h2>The Code</h2>
<p>In your <strong>embeds/navigation </strong>template, place the following code:</p>
<pre>&lt;ul id="nav"&gt;
   {exp:weblog:categories parent_only="yes" style="linear"}
      &lt;li&gt;
         {exp:query sql="SELECT cat_id FROM exp_categories WHERE parent_id = '{category_id}' LIMIT 1"}
            &lt;a href="{path='SITE_INDEX'}"{if '{total_results}' &gt; 0} class="fly"{/if}&gt;{category_name}&lt;/a&gt;
            {if '{total_results}' &gt; 0}{embed="embeds/subcategories" cat_id="{category_id}"}{/if}
         {/exp:query}
      &lt;/li&gt;
   {/exp:weblog:categories}
&lt;/ul&gt;</pre>
<p>If you&#8217;re scratching your head about what that all means, here it is:</p>
<ul>
<li>First, we use the <a href="http://expressionengine.com/docs/modules/weblog/categories.html">exp:weblog:categories</a> tag pair to show a list of all categories. We show only top-level categories by using the <strong>parent_only=&#8221;yes&#8221; </strong>parameter.</li>
<li>Next, we output a link to the category and display the name (using <strong>{path=&#8217;SITE_INDEX&#8217;} </strong>removes the &#8220;category&#8221; segment from the URL). The {exp:query} call allows us to add a class of &#8220;fly&#8221; to anchors that are associated with parent categories. This is useful if you&#8217;d like to add styling to your parent categories (<a href="http://www.3roadsmedia.com/sandbox/index.php/site/">see the demo</a> for an example).</li>
<li>The {exp:query} call also checks to see if your top-level categories have children. If so, call the <strong>embeds/subcategories </strong>template.</li>
</ul>
<p>In your <strong>embeds/subcategories </strong>template, place the following code:</p>
<pre>&lt;ul&gt;
   {exp:subcategories root_node="{embed:cat_id}"}
      &lt;li&gt;
         &lt;a href="{homepage}/category/{category_url}"{if '{subcategories_count}' &gt; 0} class="fly"{/if}&gt;{category_name}&lt;/a&gt;
         {if '{subcategories_count}' &gt; 0}{embed="embeds/sub_subcategories" subcat_id="{category_id}"}{/if}
      &lt;/li&gt;
   {/exp:subcategories}
&lt;/ul&gt;</pre>
<p>Here is an explanation of the code:</p>
<ul>
<li>We passed in the parent&#8217;s category ID as <strong>cat_id</strong>. The subcategories plugin takes this value in the <strong>root_node </strong>parameter to pull a list of subcategories.</li>
<li>For each subcategory, output a link. The Subcategories plugin has a neat variable called {subcategories_count}, which lets us replace the SQL query that you see in the embeds/navigation template. If there are subcategories, apply a class of &#8220;fly&#8221; to the anchor. This lets us style our anchors to indicate that there are more dropdowns/flyouts.</li>
<li>Lastly, use the {subcategories_count} variable to see if the current subcategory has subcategories of its own. If so, call the <strong>sub_subcategories </strong>template.</li>
</ul>
<p>In your<strong> embeds/sub_subcategories</strong> template, place the following code:</p>
<pre>&lt;ul&gt;
   {exp:subcategories root_node="{embed:subcat_id}"}
      &lt;li&gt;
         &lt;a href="{homepage}/category/{category_url}"&gt;{category_name}&lt;/a&gt;
      &lt;/li&gt;
   {/exp:subcategories}
&lt;/ul&gt;</pre>
<p>Note how similar this code is to the embeds/subcategories code. The only difference is that we did not check to see if the grandchild categories had subcategories of their own. We can easily do this by adding the following line&#8230;</p>
<pre>{if '{subcategories_count}' &gt; 0}{embed="embeds/sub_sub_subcategories" subcat_id="{category_id}"}{/if}</pre>
<p>&#8230;and then creating an <strong>embeds/sub_sub_subcategories</strong> template. In this way, you can create as many levels of menus as you want.</p>
<h2>Enjoy</h2>
<p>Adding category based dropdown menus to an ExpressionEngine website doesn&#8217;t have to be a drag. This tutorial should get you up and running without trouble; however, if you find bugs or see ways to improve the examples here, let us know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/multilevel-dropdown-category-navigation-in-expressionengine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to install and configure sIFR</title>
		<link>http://www.3roadsmedia.com/blog/how-to-install-and-configure-sifr/</link>
		<comments>http://www.3roadsmedia.com/blog/how-to-install-and-configure-sifr/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 00:05:41 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Developer's Toolbox]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/wordpress/?p=955</guid>
		<description><![CDATA[Using sIFR (scalable Inman Flash Replacement) to replace standard web fonts on our web projects has become a de facto standard for us. Since I use it so often, I wrote a quick tutorial to show you how to get sIFR up and running. This tutorial is geared toward both the novice user installing sIFR [...]]]></description>
			<content:encoded><![CDATA[<p>Using sIFR (scalable Inman Flash Replacement) to replace standard web fonts on our web projects has become a de facto standard for us. Since I use it so often, I wrote a quick tutorial to show you how to get sIFR up and running.</p>
<p>This tutorial is geared toward both the novice user installing sIFR for the first time and to those who have done it many times before. If this is your first time working with sIFR, you should know a few things before getting started:</p>
<p><span id="more-955"></span></p>
<ul>
<li>To work with sIFR and follow along here, you&#8217;ll need Adobe Flash.</li>
<li>sIFR requires both JavaScript and Flash to work. In the absence of either, it will fall back to displaying regular text.</li>
<li>Don&#8217;t try testing sIFR locally, or nothing will work. It needs to run on a server, either remotely or on a local XAMPP install.</li>
<li>sIFR is not intended to replace large blocks of text. Try to use it sparingly, for headers and small snippets of copy only. Too much sIFR will bog down your site, increasing page load times.</li>
</ul>
<h3>1. Accommodate those without JavaScript</h3>
<p>The very first thing you should do is to make sure your to-be-replaced text looks correct <em>before using sIFR to replace it</em>. If you don&#8217;t do this now, you&#8217;ll spend more time later switching between your sIFR text and your regular text (they end up using different stylesheets) to make sure they both look right. It&#8217;s better to take care of the non-JavaScript people first.</p>
<p>When you&#8217;ve gotten your text where you want it, move on to step #2.</p>
<h3>2. Download the sIFR files</h3>
<p><a href="http://dev.novemberborn.net/sifr3/nightlies/">Download the latest version of sIFR</a> and unzip it somewhere on your computer. For this tutorial, we&#8217;ll be working with sIFR release 436.</p>
<h3>3. Open sifr.fla</h3>
<p>When you unzip the sIFR archive, you&#8217;ll see four folders: css, demo, flash, and js. You can completely ignore the <em>demo </em>folder. Click into the flash folder and open <strong>sifr.fla</strong>.</p>
<h3>4. Modify sifr.fla</h3>
<p>Once you&#8217;ve opened sifr.fla, you should see something like this:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_empty-stage.png"><img class="aligncenter size-medium wp-image-960" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_empty-stage-300x195.png" alt="sifr_empty-stage" width="300" height="195" /></a></p>
<p>The white rectangle in the middle is called the <em>stage </em>or the <em>canvas. </em><strong>Double click it </strong>and you&#8217;ll see this:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_active-stage.png"><img class="aligncenter size-medium wp-image-961" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_active-stage-300x195.png" alt="sifr_active-stage" width="300" height="195" /></a></p>
<p>Double click the stage again to select the text inside. Delete everything, then <strong>type a single character (glpyh) of your choice for each font style you&#8217;d like. </strong>For instance, if you only need normal and bold styles, enter two glyphs: one for normal and one for bold<strong>. Make sure all of your glyphs are the same letter.</strong><strong><br />
</strong></p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_glyphs-on-stage.png"><img class="aligncenter size-medium wp-image-963" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_glyphs-on-stage-300x195.png" alt="Click to enlarge" width="300" height="195" /></a></p>
<p>Of course, you&#8217;ll have to choose a font that supports all of the styles you need. <strong>In this tutorial, I&#8217;m using Arno Pro</strong>, which has bold, italic, and bold italic glyphs.</p>
<h3>5. Choose your font</h3>
<p>Select all of your glyphs, then look to the right of your screen for a dropdown menu like the one highlighted below:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_choose-font.png"><img class="aligncenter size-medium wp-image-964" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_choose-font-300x195.png" alt="Click to enlarge" width="300" height="195" /></a></p>
<p>All of your characters will now be the default &#8220;normal&#8221; style of the chosen font. If your font supports additional styles, the &#8220;Style&#8221; menu will be active. Highlight each individual glyph you want to change, then choose a different style from the dropdown. In the example below, I&#8217;m about to make the second glyph italic:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_choose-italic.png"><img class="aligncenter size-medium wp-image-965" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_choose-italic-300x195.png" alt="Click to enlarge" width="300" height="195" /></a></p>
<p>For fonts like Arno Pro, which have tons of glyph styles, you may be tempted to pick a &#8220;caption&#8221; or &#8220;extra wide&#8221; style. <strong>These will not work, </strong>since HTML only supports normal, bold, italic, and bold italic.</p>
<blockquote><p>TIP: If you only need to display one style on your site, then you only need one glyph on your stage. I.e., if you only want to display bold, then type one glyph and bold it. You don&#8217;t need any more than that.</p></blockquote>
<h3>6. Add additional glyphs</h3>
<p>If you anticipate using special characters (for example, Ñ, β, £, «, ™), you&#8217;ll need to embed them in your Flash movie. Right beneath the menus you just worked with is a &#8220;Character Embedding&#8221; button which, when clicked, pops up a window like this:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_embed-chars.png"><img class="aligncenter size-medium wp-image-966" title="Click to enlarge" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_embed-chars-300x195.png" alt="Click to enlarge" width="300" height="195" /></a></p>
<p>The basic glyph sets are already chosen for you, along with a list of extra characters. Choose the additional character sets you want (if any) or type special characters in the list, then click OK.</p>
<h3>7. Publish your movie</h3>
<p>When you&#8217;re happy with your font, go to <strong>File › Publish Settings.</strong> Untick the box near &#8220;HTML&#8221; since we won&#8217;t need to output any HTML files. Next, click the &#8220;Flash&#8221; tab near the top to adjust your settings.</p>
<p>The only setting you should change is <strong>JPEG quality. </strong>I always set it to 100, since there&#8217;s almost never a difference in file size between 80 and 100. This ensures your replaced text looks as good as possible. You can, of course, adjust this setting to try and reduce the size of your Flash movie.</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_set-jpeg.png"><img class="size-full wp-image-967 aligncenter" title="Publish settings for the sIFR Flash movie" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_set-jpeg.png" alt="Click to enlarge" width="456" height="676" /></a></p>
<p>Once this is set, click <strong>Publish</strong>.</p>
<h3>8. Rename your movie</h3>
<p>Go back to the folder that has your sIFR files and click into the &#8220;flash&#8221; folder. You should now see a <strong>sifr.swf</strong> file, which is the movie you just published.</p>
<p>It&#8217;s good practice to rename your movie after the font it contains, since it&#8217;s not uncommon to replace more than one font on a website. This naming convention will make it easy to know what&#8217;s what.</p>
<p>I renamed my movie <strong>arnopro.swf</strong>.</p>
<h3>9. Open sifr-config.js and configure</h3>
<p>Now it&#8217;s time for the hearty, meat-and-potatoes part of the tutorial. You&#8217;ve got your movie; you just need to tell your site where to find it and what to do with it.</p>
<p>Go to your sIFR folder, click into the &#8220;js&#8221; folder, and open <strong>sifr-config.js</strong>.</p>
<p>There are instructions in the file, but here are the basics:</p>
<ul>
<li>On line 15, change the variable name to match your font&#8217;s name and change the path to point to your swf file. For example:</li>
</ul>
<pre><span style="color: #888888;">// what you see when you open the file</span>
<span style="color: #000080;">var</span> futura <span style="color: #000080;">= {</span> src<span style="color: #0000ff;">: '/path/to/futura.swf'</span> <span style="color: #000080;">}</span>;
<span style="color: #888888;">
// an example of what you should change it to</span>
<span style="color: #000080;">var</span> arnopro <span style="color: #000080;">= {</span> src<span style="color: #0000ff;">: 'http://www.3roadsmedia.com/flashstuff/arnopro.swf'</span> <span style="color: #000080;">}</span>;</pre>
<ul>
<li>Now is a good time to upload everything to a web server so you know the path to your movie. <strong>You won&#8217;t be able to test sIFR by just calling the movie from your hard drive.</strong></li>
<li>Do a find/replace to swap out all instances of <strong>futura </strong>with the name of your new font.</li>
<li>Tell sIFR how to display your new font by adding CSS selectors and style rules (see the next step)</li>
</ul>
<h3>10. Tell sIFR how to display your new font</h3>
<p>All of the styling for your Flash-based font is handled via <strong>sifr-config.js</strong>, starting on line 53.</p>
<p>A couple of pointers:</p>
<ul>
<li>Be sure the font name after <strong>sIFR.replace</strong> matches the name you specified in line 15</li>
<li>The &#8220;selector:&#8221; tells sIFR which HTML element to target with the style rules. sIFR supports <a href="http://wiki.novemberborn.net/sifr3/Selectors">most HTML elements</a>, but if you want to target things like :first-child, <a href="http://wiki.novemberborn.net/sifr3/parseSelector">read this article</a> on how to do it.</li>
<li>You can target multiple selectors at a time by using a comma-separated list; e.g.:</li>
</ul>
<pre>selector<span style="color: #0000ff;">: 'h1, h2 a, #footer h3'</span>,</pre>
<ul>
<li>When using hex colors, <strong>always use the full six digits. </strong>Three-digit CSS shortcuts do <em>not </em>work here. For instance, use #003300, <em>not </em>#030.</li>
<li>If you&#8217;re getting a funky colored box behind your replaced text, add this line to each of your selectors:</li>
</ul>
<pre>wmode<span style="color: #0000ff;">: 'transparent'</span></pre>
<ul>
<li>To style hyperlink <strong>hover </strong>behavior, do something like the following:</li>
</ul>
<pre>css<span style="color: #0000ff;">: [
   '.sIFR-root { color: #000000; }',
   'a { color:#9f2321; text-decoration:none; }',
   'a:hover { color:#99e232; text-decoration:underline; }'
   ]</span></pre>
<h3>11. Include the sIFR files in your web page</h3>
<p>For this tutorial, I&#8217;m assuming you already know how you want to style your font, so you can configure first and hook up second (sounds like I&#8217;m inviting some derisive snickering&#8230;).</p>
<p>sIFR requires 3 files to work: sifr.css, sifr.js, and sifr-config.js.</p>
<p>Add these files to the &lt;head&gt; section of your web pages by copying/pasting this:</p>
<pre><span style="color: #808080;">&lt;!-- sIFR files --&gt;</span>
<span style="color: #000080;">&lt;link rel=</span><span style="color: #0000ff;">"stylesheet"</span> <span style="color: #000080;">type=</span><span style="color: #0000ff;">"text/css"</span> <span style="color: #000080;">href=</span><span style="color: #0000ff;">"http://path/to/sifr.css"</span> <span style="color: #000080;">/&gt;</span>
<span style="color: #800000;">&lt;script type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #800000;">src=</span><span style="color: #0000ff;">"http://path/to/sifr.js"</span><span style="color: #800000;">&gt;&lt;/script&gt;</span>
<span style="color: #800000;">&lt;script type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #800000;">src=</span><span style="color: #0000ff;">"http://path/to/sifr-config.js"</span><span style="color: #800000;">&gt;&lt;/script&gt;</span></pre>
<h3>12. Upload everything and test</h3>
<p>Upload everything to your web server and load your web page. If all went as planned, you should see your new font instead of that old, dreary thing you&#8217;re replacing:</p>
<p style="text-align: center;"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_font-final.png"><img class="aligncenter size-full wp-image-968" title="A before and after shot. Much better." src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/10/sifr_font-final.png" alt="A before and after shot. Much better." width="452" height="222" /></a></p>
<p>If you <em>don&#8217;t </em>see your new font, go through this checklist:</p>
<ul>
<li>Double check the paths to all of your files.</li>
<li>If your JS files are linked properly, make sure you entered the right path on line 15 of sifr-config.js.</li>
<li>If <em>that&#8217;s </em>linked properly, try to load the Flash movie directly. If you don&#8217;t get anything, you may not have Flash installed or it may be turned off.</li>
<li>Make sure JavaScript is enabled in your browser.</li>
</ul>
<p>Once you&#8217;ve got your replaced font showing, tweak your CSS in sifr-config.js until things are exactly where you want them.</p>
<h3>13. Tweak the CSS</h3>
<p>The final step is to tweak your replaced text. You may notice it&#8217;s a bit off in some places, or that it wraps in the middle of a word. The solution is to edit <strong>sifr.css</strong>, which is located in the &#8220;css&#8221; folder of your sIFR download.</p>
<p>Once you&#8217;ve opened that file, scroll to the very bottom, where you&#8217;ll see this:</p>
<pre><span style="color: #800000;">@media screen {</span>
<span style="color: #808080;"> /* Example:
 .sIFR-active h1 {
 font-family: Verdana;
 visibility: hidden;
 }
 */</span>
<span style="color: #800000;">}</span></pre>
<p>This is where you make your edits (you can leave the rest of the file alone).</p>
<p>A common fix you may need to implement is <strong>preventing your replaced text from wrapping in the middle of a word</strong>. This is caused by the replaced text taking up less space than the sIFR text. The solution is to increase the font size, letter-spacing, or width of the replaced text. If you do this in your <em>regular </em>CSS file, you may find that your regular (non-sIFR) text is too large.</p>
<p>In this case, you&#8217;d create a new rule in your sifr.css file to make the font larger <em>only for the replaced text</em>; e.g.:<em><br />
</em></p>
<pre><span style="color: #888888;">// regular CSS file</span>
<span style="color: #ff00ff;">h1 {</span> <span style="color: #0000ff;">font-size</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">20px</span><span style="color: #ff00ff;">; }</span>

<span style="color: #888888;">// sifr.css</span>
<span style="color: #ff00ff;">.sIFR-active h1 {</span> <span style="color: #0000ff;">font-size</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">28px</span><span style="color: #ff00ff;">;</span> <span style="color: #0000ff;">visibility</span><span style="color: #ff00ff;">:</span><span style="color: #0000ff;">hidden</span><span style="color: #ff00ff;">; }</span><span style="color: #ff00ff;"> </span></pre>
<p>Regardless of whether you edit sifr.css, you must include it in your &lt;head&gt; section.</p>
<h2>Post script: frequently asked questions</h2>
<p>You&#8217;ve got sIFR up and running, but something isn&#8217;t acting quite right? I&#8217;ve compiled this short list of questions that I&#8217;ve seen asked many times before:</p>
<h3>How do I adjust line-height in sIFR?</h3>
<p>Flash doesn&#8217;t understand the concept of line-height. Instead, it uses a custom property called <strong>leading. </strong>To adjust the line-height in sIFR, do this in your sifr-config file:</p>
<pre>// leading must be a number (decimals allowed); no units needed
css<span style="color: #0000ff;">: '.sIFR-root { color:#5a3b00; font-size:25px; <strong>leading: -3;</strong> }'</span>,</pre>
<h3>How do I style links in sIFR? My cursor doesn&#8217;t work.</h3>
<p>A common problem with sIFR-replaced links is that your cursor doesn&#8217;t appear as the friendly hand pointer, but as a text selector. This is because you haven&#8217;t replaced the link, but the text <em>inside </em>the link. <a href="http://wiki.novemberborn.net/sifr/FAQ#replacing-links">Read here</a> for how to fix this.</p>
<h2>That&#8217;s it!</h2>
<p>If you have suggestions for improving this tutorial, or if you get stuck, feel free to leave a comment. You can also post a question at <a href="http://stackoverflow.com/">Stack Overflow</a> where Mark Wubben (lead sIFR developer) is great at answering questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/how-to-install-and-configure-sifr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Improving WordPress page navigation: fixing next_post_link() and previous_post_link()</title>
		<link>http://www.3roadsmedia.com/blog/improving-wordpress-page-navigation/</link>
		<comments>http://www.3roadsmedia.com/blog/improving-wordpress-page-navigation/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:06:07 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Developer's Toolbox]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/?p=746</guid>
		<description><![CDATA[WordPress&#8217; next_post_link() and previous_post_link() functions are used to navigate between posts in single post (permalink) view. They work great&#8230;until you come to the very first or the very last post. When viewing the latest post, next_post_link() displays nothing; when viewing the earliest post, previous_post_link() displays nothing. This can result in some less than friendly navigation. [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress&#8217; next_post_link() and previous_post_link() functions are used to navigate between posts in single post (permalink) view. They work great&#8230;until you come to the very first or the very last post.</p>
<p>When viewing the latest post, <strong>next_post_link() </strong>displays nothing; when viewing the earliest post, <strong>previous_post_link() </strong>displays nothing. This can result in some less than friendly navigation.</p>
<p><strong>In this post, </strong><strong>I&#8217;ll show you how to use a built-in WordPress function and PHP conditionals to improve your WordPress page navigation.</strong><br />
<span id="more-746"></span></p>
<h2>The problem</h2>
<p>Here is an example of <strong>next_post_link() </strong>and <strong>previous_post_link() </strong>at work on our blog&#8217;s old theme:</p>
<div id="attachment_756" class="wp-caption aligncenter" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_example.png"><img class="size-full wp-image-756  " title="wp_post_functions_example" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_example.png" alt="wp_post_functions_example" width="480" height="119" /></a><p class="wp-caption-text">When viewing a post that is neither the newest nor the oldest, the post navigation links display as expected.</p></div>
<p>The trouble with these functions comes when you get to the first or last post. In the case of the first, you&#8217;ll have something like this:</p>
<div id="attachment_757" class="wp-caption aligncenter" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_missing_previous.png"><img class="size-full wp-image-757  " title="wp_post_functions_missing_previous" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_missing_previous.png" alt="wp_post_functions_missing_previous" width="480" height="119" /></a><p class="wp-caption-text">When viewing the oldest post, the &quot;previous post&quot; link disappears, leaving an ugly hole.</p></div>
<p>And when viewing the last post, you&#8217;ll have something like this:</p>
<div id="attachment_758" class="wp-caption aligncenter" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_missing_next.png"><img class="size-full wp-image-758  " title="wp_post_functions_missing_next" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_missing_next.png" alt="wp_post_functions_missing_next" width="480" height="119" /></a><p class="wp-caption-text">Similarly, when viewing the newest post, the &quot;next post&quot; link disappears.</p></div>
<h2>To the rescue: get_adjacent_post</h2>
<p>We&#8217;re going to use the obscure WordPress function <strong>get_adjacent_post()</strong> to check if&#8230; (shockingly) &#8230;there is an adjacent post. If there isn&#8217;t, we output whatever HTML markup we like to take the place of the gaping hole we&#8217;re trying to fill. If there <em>is </em>an adjacent post, we output it as normal.</p>
<p>The function retrieves a link to the adjacent post (either next or previous) and takes the following form&#8230;</p>
<pre>get_adjacent_post([bool $in_same_cat, string $excluded_categories, bool $previous])</pre>
<p>&#8230;and has these parameters:</p>
<ul>
<li><strong>$in_same_cat</strong> : Whether the link should be in the same category</li>
<li><strong>$excluded_categories</strong> : A comma-separated list of excluded category IDs</li>
<li><strong>$previous</strong> : Whether to retrieve the previous post</li>
</ul>
<h2>The solution, with sample markup</h2>
<p>The code block below contains the markup you should add to your <strong>single.php</strong> template file. Place it where you&#8217;d like your navigation to appear, then adjust the parameters and output to suit your needs.</p>
<pre><span style="color: #000080;">&lt;span id=<span style="color: #0000ff;">"prev"</span>&gt;</span>
   <span style="color: #ff0000;">&lt;?php</span> previous_post_link<span style="color: #000080;">(</span><span style="color: #ff0000;">'%link'</span>, <span style="color: #ff0000;">'&amp;laquo; Previous'</span><span style="color: #000080;">)</span>; <span style="color: #ff0000;">?&gt;</span>
   <span style="color: #ff0000;">&lt;?php</span> <span style="color: #008000;">if</span><span style="color: #000080;">(!</span>get_adjacent_post<span style="color: #000080;">(</span><span style="color: #008000;">false</span>, <span style="color: #ff0000;">''</span>, <span style="color: #008000;">true</span><span style="color: #000080;">))</span> <span style="color: #000080;">{</span> <span style="color: #0000ff;">echo </span><span style="color: #ff0000;">'&lt;span&gt;&amp;laquo;Previous&lt;/span&gt;'</span>; <span style="color: #000080;">}</span> <span style="color: #ff9900;">// if there are no older articles</span> <span style="color: #ff0000;">?&gt;</span>
<span style="color: #000080;">&lt;/span&gt;</span>
<span style="color: #000080;">&lt;span id=<span style="color: #0000ff;">"next"</span>&gt;</span>
   <span style="color: #ff0000;">&lt;?php</span> next_post_link<span style="color: #000080;">(</span><span style="color: #ff0000;">'%link'</span>, <span style="color: #ff0000;">'Next &amp;raquo;'</span><span style="color: #000080;">)</span>; <span style="color: #ff0000;">?&gt;</span>
   <span style="color: #ff0000;">&lt;?php</span> <span style="color: #008000;">if</span><span style="color: #000080;">(!</span>get_adjacent_post<span style="color: #000080;">(</span><span style="color: #008000;">false</span>, <span style="color: #ff0000;">''</span>, <span style="color: #008000;">false</span><span style="color: #000080;">))</span> <span style="color: #000080;">{</span> <span style="color: #0000ff;">echo </span><span style="color: #ff0000;">'&lt;span&gt;Next &amp;raquo;&lt;/span&gt;'</span>; <span style="color: #000080;">}</span> <span style="color: #ff9900;">// if there are no newer articles</span> <span style="color: #ff0000;">?&gt;</span>
<span style="color: #000080;">&lt;/span&gt;</span></pre>
<p>I then added this line to my CSS file:</p>
<pre><span style="color: #ff00ff;">#prev span, #next span { <span style="color: #000080;">color</span>:<span style="color: #0000ff;">#ccc</span>; }</span> <span style="color: #999999;">/* lighter than the normal anchor text */</span></pre>
<p>And here is the final result:</p>
<div id="attachment_759" class="wp-caption aligncenter" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_result.png"><img class="size-full wp-image-759  " title="wp_post_functions_result" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads//2009/09/wp_post_functions_result.png" alt="wp_post_functions_result" width="480" height="238" /></a><p class="wp-caption-text">The final result, showing user-friendly language at both ends.</p></div>
<p>In the example above, I grayed out the inactive links. If you have more room, you might get creative by replacing the text with something like &#8220;Sorry, there aren&#8217;t any newer posts!&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/improving-wordpress-page-navigation/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>Use a ModalBox to edit content inline with ExpressionEngine</title>
		<link>http://www.3roadsmedia.com/blog/use-a-modal-box-to-edit-content-inline-with-expressionengine/</link>
		<comments>http://www.3roadsmedia.com/blog/use-a-modal-box-to-edit-content-inline-with-expressionengine/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 20:59:20 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Developer's Toolbox]]></category>
		<category><![CDATA[Expression Engine]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/?p=437</guid>
		<description><![CDATA[A couple months ago, I wrote a post on how to use AJAX to edit content inline &#8211; without accessing the control panel and without a page refresh. Since then, I&#8217;ve found a much cooler and more practical way of editing content inline: by using a modal box. The result is the same: authorized users [...]]]></description>
			<content:encoded><![CDATA[<p>A couple months ago, I wrote a post on <a href="http://www.3roadsmedia.com/wordpress/inline-editing-with-expressionengine-and-ajax/">how to use AJAX to edit content inline</a> &#8211; without accessing the control panel and without a page refresh.</p>
<p>Since then, I&#8217;ve found a much cooler and more practical way of editing content inline: by using a <a href="http://en.wikipedia.org/wiki/Modal_window">modal box</a>. The result is the same: authorized users can update certain content blocks without control panel access and without any knowledge of HTML.</p>
<p>In fact, I think this method is far more robust, flexible, and user friendly than the AJAX one I shared with you a while back.</p>
<p>Let&#8217;s get started.</p>
<h2>What is a modal box?</h2>
<p>If you already know what a modal box is and why you would use it with ExpressionEngine, feel free to <a href="#step1">skip ahead</a> to the implementation.</p>
<p>A modal box is a JavaScript driven dialogue box that &#8220;pops over&#8221; a page&#8217;s content. It is not a separate popup window, so it won&#8217;t be blocked by a user&#8217;s browser. Perhaps most importantly, a modal box requires the user to interact with it before the user can do anything else on the page.</p>
<div id="attachment_440" class="wp-caption aligncenter" style="width: 490px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modal-box-example.jpg"><img class="size-full wp-image-440  " title="modal-box-example" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modal-box-example.jpg" alt="A simple modal box" width="480" height="346" /></a><p class="wp-caption-text">A simple modal box</p></div>
<p><span id="more-593"></span></p>
<h3>Why use a modal box for inline editing?</h3>
<p>Usability. A modal box does not require the user to leave the current page, which means a user can interact with the dialogue (or series of dialogues) while still seeing the same page in the background.</p>
<p>For ExpressionEngine users in particular, <strong>not having to leave the page you want to edit is a big bonus</strong>, since finding a particular weblog entry in the control panel can be time consuming.</p>
<h3>Can I see a demonstration?</h3>
<p><a href="http://www.3roadsmedia.com/sandbox/index.php/modalbox_test/index/">Here is the end result</a> of this tutorial. Feel free to make some changes &#8211; these are posting to an actual EE database so you can see how this method works.</p>
<p>You can also go to <a href="http://www.wildbit.com/labs/modalbox/">Wildbit&#8217;s Modal Box page</a> and check out the demos.</p>
<h3>Getting a modal box to work with ExpressionEngine</h3>
<p>The goal for this tutorial is to implement a modal box that allows us to edit the content of an ExpressionEngine weblog entry <strong>inline</strong>; that is, without control panel access.</p>
<h4 id="step1">Step 1: Create a new weblog, custom fields, and template group</h4>
<p>To be as comprehensive as possible, I&#8217;ll assume that you&#8217;re starting with a fresh EE install. If you already have weblogs set up, <a href="#step2">skip to the next step</a>.</p>
<p>Create a new weblog (in a flash of brilliance, I named mine &#8220;ModalBox Test&#8221; and gave it a short name of <strong>modalbox_test</strong>).</p>
<p>Create a new custom field group (or use the default one). Make sure it has at least one text input field type and one textarea field type. I set the formatting for my fields to &#8220;none,&#8221; but you don&#8217;t have to.</p>
<div id="attachment_443" class="wp-caption aligncenter" style="width: 500px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-ee-custom-fields.png"><img class="size-full wp-image-443 " title="modalbox-ee-custom-fields" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-ee-custom-fields.png" alt="I created two custom fields for this tutorial. Use the short names above if you plan to follow this tutorial to a T." width="490" height="146" /></a><p class="wp-caption-text">Use the short names above if you plan to follow this tutorial to a T.</p></div>
<p>Assign your field group to your modalbox_test weblog.</p>
<p>Create a new template group. I called mine <strong>modalbox_test</strong>, the same as the weblog.</p>
<h4 id="step2">Step 2: Grab the ModalBox files</h4>
<p>Visit Wildbit&#8217;s site and <a href="http://www.wildbit.com/labs/modalbox/">download the latest version of ModalBox</a> (I&#8217;m using 1.6.0 for this tutorial).</p>
<p>Extract the zip file on your computer, then upload the <strong>modalbox1.6.0</strong> folder to your web server. For this tutorial, I renamed my modalbox1.6.0 folder to <strong>modalbox </strong>and uploaded it to my <strong>system/scripts </strong>folder (this folder does not exist by default, so you will have to create it).</p>
<div id="attachment_442" class="wp-caption aligncenter" style="width: 500px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-folder-location1.png"><img class="size-full wp-image-442 " title="modalbox-folder-location1" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-folder-location1.png" alt="For the visually inclined." width="490" height="186" /></a><p class="wp-caption-text">For the visually inclined.</p></div>
<p>The <strong>system </strong>folder is EE&#8217;s default system folder. You may have renamed it to something else.</p>
<h4>Step 3: Link the ModalBox files to your template</h4>
<p>I&#8217;ve prepared the following code block that you can use in your new template. If you&#8217;re using my custom field names from <a href="#step1">Step #1</a>, you don&#8217;t need to change anything. Otherwise, be sure to replace my custom field names with your own.</p>
<p>Copy and paste the following code into your <strong>modalbox_test/index</strong> template (the calls to the ModalBox files are in <span style="color: #ff0000;"><strong>red boldface</strong></span>):</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
    &lt;title&gt;Inline Editing with Modal Boxes&lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" href="{stylesheet=weblog/stylesheet}" /&gt;

    &lt;!-- Modalbox files --&gt;
<span style="color: #ff0000;"><strong>    &lt;script type="text/javascript" src="{scripts}/modalbox/lib/prototype.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="{scripts}/modalbox/lib/scriptaculous.js?load=effects"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="{scripts}/modalbox/modalbox.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" type="text/css" href="{scripts}/modalbox/modalbox.css" media="screen" /&gt;</strong></span>
    &lt;!--// Modalbox files --&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;An example of inline editing with ExpressionEngine and Modal Boxes&lt;/h1&gt;

&lt;ul&gt;
    {exp:weblog:entries disable="categories|member_data|pagination|trackbacks" weblog="modalbox_test"}
        &lt;li&gt;
            &lt;h2&gt;{title}&lt;/h2&gt;
            &lt;p&gt;&lt;strong&gt;{modalbox_input}&lt;/strong&gt;&lt;/p&gt;
            &lt;p&gt;{modalbox_textarea}&lt;/p&gt;
        &lt;/li&gt;
    {/exp:weblog:entries}
&lt;/ul&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Notice the {scripts} variable. </strong>That is a global variable I set up in EE that contains the path to my scripts folder (e.g., http://www.yoursite.com/system/scripts).</p>
<h4>Step 4. Add an &#8220;Edit&#8221; link</h4>
<p>Before you go any further, add some test entries, then preview your template to make sure everything is hooked up correctly.</p>
<p>Once that&#8217;s done, add the following line of code to your template. Place it where you&#8217;d like the &#8220;Edit&#8221; link to appear (I placed mine right below the &lt;h2&gt; tags in the sample code).</p>
<pre>{if logged_in}&lt;a onclick=<code><span style="color: #000000;"><span style="color: #dd0000;">"Modalbox.show($('modalbox-content-{entry_id}'), {title: this.title, width: 800}); return false;" </span><span style="color: #0000bb;">title</span><span style="color: #007700;">=</span><span style="color: #dd0000;">"Edit this weblog entry" </span><span style="color: #0000bb;">href</span><span style="color: #007700;">=</span><span style="color: #dd0000;">"#"</span><span style="color: #007700;">&gt;</span><span style="color: #0000bb;">Edit</span><span style="color: #007700;">&lt;/</span><span style="color: #0000bb;">a</span><span style="color: #007700;">&gt;{/if}</span></span></code></pre>
<p>This line of code tells the ModalBox script to load a DIV with an ID of <strong>modalbox-content-XX</strong> (where XX is the entry&#8217;s ID) into a ModalBox that is 800 pixels wide with a heading of &#8220;Edit weblog entry.&#8221;</p>
<h4>Step 5. Create the DIV</h4>
<p>In the previous step, we told ModalBox to find and display a DIV with a particular ID. This DIV will contain a SAEF (<a href="http://expressionengine.com/wiki/Hard_Coded_Stand_Alone_EDIT_Form_Guide/">stand alone edit form</a>), which allows us to easily and safely post our changes to the EE database.</p>
<p><a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/06/SAEF.txt">Grab the SAEF code here</a> and paste it wherever you like in your main template, so long as it is within the {exp:weblog:entries} tags.</p>
<p>The only thing you&#8217;ll need to change in the SAEF are the custom field ID numbers associated with each of your custom fields.</p>
<p>What?</p>
<p>When you created custom fields for your weblog, ExpressionEngine assigned each of them a unique ID number. We need to know what these numbers are in order to pull the correct information from the database.</p>
<p><strong>To find these numbers</strong>, go to Admin › Weblog Administration › Custom Weblog Fields, then click &#8220;Add/Edit Custom Fields&#8221; next to the field group you created for this tutorial. Mouse over each of your custom fields and note the number that appears in the bottom left of your browser:</p>
<div id="attachment_444" class="wp-caption aligncenter" style="width: 509px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-ee-custom-field-id-explanation.png"><img class="size-full wp-image-444 " title="modalbox-ee-custom-field-id-explanation" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/05/modalbox-ee-custom-field-id-explanation.png" alt="How to find a field ID for your custom fields" width="499" height="251" /></a><p class="wp-caption-text">How to find a field ID for each of your custom fields</p></div>
<p>Here are my field IDs:</p>
<ul>
<li>modalbox_input: <strong>73</strong></li>
<li>modalbox_textarea: <strong>74</strong></li>
</ul>
<p>In your SAEF, find any references to these field IDs. <strong>They will look like field_id_XX, where XX is the field ID</strong>. For example, I would change my SAEF to look like this (my changes are in <span style="color: #ff0000;"><strong>red</strong></span>):</p>
<pre>&lt;label for="amount"&gt;Modalbox Input&lt;/label&gt;
&lt;input type="text" name="<strong>field_id_<span style="color: #ff0000;">73</span></strong>" id="amount" value="{modalbox_input}" /&gt;
&lt;input type="hidden" name="<strong>field_ft_<span style="color: #ff0000;">73</span></strong>" value="none" /&gt;

&lt;label for="details"&gt;Modalbox Textarea&lt;/label&gt;
&lt;textarea name="<strong>field_id_<span style="color: #ff0000;">74</span></strong>" id="details"&gt;{modalbox_textarea}&lt;/textarea&gt;
&lt;input type="hidden" name="<strong>field_ft_<span style="color: #ff0000;">74</span></strong>" value="none" /&gt;</pre>
<p><strong>The field_ft_XX lines control the formatting for a particular field</strong>. You can leave them set to &#8220;none&#8221; to remove all HTML formatting.</p>
<h4>Step 6. Test your ModalBox</h4>
<p>Save and preview your template, then click an &#8220;Edit&#8221; link to call the ModalBox. If you&#8217;ve followed along closely, you&#8217;ll see a form populated with your weblog entry&#8217;s content.</p>
<div id="attachment_464" class="wp-caption aligncenter" style="width: 510px"><a rel="post-image" href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/06/modalbox-success.png"><img class="size-full wp-image-464 " title="The results of our hard work" src="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/06/modalbox-success.png" alt="The results of our hard work" width="500" height="207" /></a><p class="wp-caption-text">The results of our hard work</p></div>
<p>Make some changes and click &#8220;Save&#8221; and you should be sent to the location specified in the &#8220;return&#8221; parameter of your SAEF. If this is the same page you just came from, you should see your changes.</p>
<h4>Step 7. Add a success message</h4>
<p>If you make a change and get dumped back on a page without any visual cues that something changed, you (or your client) may not have a clue what just happened.</p>
<p>That&#8217;s why I suggest adding a success message.</p>
<p>First, alter the <strong>return </strong>parameter in your SAEF to include the following:</p>
<pre>return="modalbox_test/index<strong>/?updated=true</strong>"</pre>
<p>You can set &#8220;updated&#8221; to be anything you like; it&#8217;s just a variable name.</p>
<p>Next, in the page you are returning to (modalbox_test/index), add the following lines of PHP:</p>
<pre class="codeblock">&lt;?php
    if(stristr($_SERVER['REQUEST_URI'], 'updated=true')) { $updated = 1; }

    if(isset($updated)) {
        echo "&lt;div&gt;Your weblog entry was successfully updated.&lt;/div&gt;";
    }
?&gt;</pre>
<p>This snippet checks the URL for the segment we just added; if it finds it, then it displays a success message.</p>
<h4>Step 8. Add a dropdown menu</h4>
<p>In my last tutorial on inline editing, I didn&#8217;t touch the subject of dropdowns, since trying to get them to work with that script was impossible.</p>
<p>Luckily, we can use the SAEF with a bit of PHP to get what we need. Add the following where you&#8217;d like your dropdown to appear in the SAEF, being sure to replace the field IDs as needed:</p>
<pre>&lt;label for="dropdown"&gt;Dropdown List&lt;/label&gt;
<span class="punct">&lt;</span><span class="ident">select</span> <span class="ident">name</span><span class="punct">="</span><strong><span class="string">field_id_<span style="color: #ff0000;">XX</span></span></strong><span class="punct">"&gt;
    {</span><span class="ident">exp</span><span class="symbol">:query</span> <span class="ident">sql</span><span class="punct">="</span><span class="string">SELECT field_list_items FROM exp_weblog_fields WHERE field_id = '<span style="color: #ff0000;"><strong>XX</strong></span>' </span><span class="punct">"}</span>
        <span class="punct">&lt;?</span>php
            <span class="global">$items</span> <span class="punct">="</span><span class="string">{field_list_items}</span><span class="punct">";</span>
            <span class="global">$items</span> <span class="punct">=</span> <span class="ident">explode</span><span class="punct">("</span><span class="string"><span class="escape">\n</span></span><span class="punct">",</span> <span class="global">$items</span><span class="punct">);</span>
<span class="global">            $howmany</span> <span class="punct">=</span> <span class="ident">count</span><span class="punct">(</span><span class="global">$items</span><span class="punct">);</span>
            <span class="global">$i</span> <span class="punct">=</span> <span class="number">0</span><span class="punct">;</span> <span class="keyword">do</span> <span class="punct">{</span>
<span class="global">            $item_id</span> <span class="punct">=</span> <span class="global">$items</span><span class="punct">[</span><span class="global">$i</span><span class="punct">];</span>
        <span class="char">?&gt;</span>
        <span class="punct">&lt;</span><span class="ident">option</span> <span class="ident">value</span><span class="punct">="</span><span class="string">&lt;?=$item_id?&gt;</span><span class="punct">"&gt;&lt;</span><span class="char">?=</span><span class="global">$item_id</span><span class="char">?&gt;</span><span class="punct">&lt;/</span><span class="regex">option&gt;
        &lt;?php
            $i++; } while ($i &lt; $howmany);
        ?&gt;
    {</span><span class="punct">/</span><span class="ident">exp</span><span class="symbol">:query</span><span class="punct">}
&lt;/</span><span class="regex">select&gt;</span></pre>
<p>This bit of code will loop through all of your manually entered dropdown items, then display them.</p>
<h4>Step 9. Enjoy!</h4>
<p>Feel free to share your own experiences, or to suggest ways to improve the code I&#8217;ve presented here. Have a question? Got stuck and need help? Let me know!</p>
<h3>Postscript: Streamlining your implementation</h3>
<p>I was fortunate enough to receive some feedback from <a href="http://www.stolpmann.eu/">Markus Stolpmann</a>, a fellow EE user, on how to improve the modalbox implementation. The steps above are fine if you don&#8217;t mind including hidden divs in your code – but what if this isn&#8217;t your cup of tea?</p>
<p>It&#8217;s far easier to maintain your code if you include the SAEF in a separate template.</p>
<p>To begin, create a new template group (something like <strong>modalboxes </strong>works well). This new group will hold all of the content shown in your modal boxes. Our company intranet, for example, has templates like:</p>
<ul>
<li>modalboxes/add_prospect</li>
<li>modalboxes/add_invoice</li>
<li>modalboxes/edit_prospect</li>
<li>modalboxes/edit_invoice</li>
</ul>
<p>Each of these templates contains a SAEF with fields specific to the task (i.e., I won&#8217;t have an &#8220;invoice number&#8221; input box in my <strong>edit_prospect </strong>template). Here is an example of what my <strong>modalboxes/edit_prospect</strong> template looks like:</p>
<pre>{exp:weblog:entry_form weblog="prospects" return="prospects/prospect_added"}
    &lt;ul&gt;
        &lt;li&gt;
            &lt;label for="title"&gt;Prospect Name&lt;em&gt;*&lt;/em&gt;&lt;/label&gt;
            &lt;input type="text" name="title" id="title" value="{title}" maxlength="100" onkeyup="liveUrlTitle();" /&gt;
        &lt;/li&gt;
        &lt;li&gt;
            &lt;label for="email"&gt;Email&lt;/label&gt;
            &lt;input type="text" name="field_id_4" id="email" /&gt;
        &lt;/li&gt;
        ...
        &lt;li&gt;
            &lt;input type="submit" name="submit" value="Edit prospect" /&gt;&amp;nbsp;or &lt;a href="#" title="Close window" onclick="Modalbox.hide()"&gt;Cancel and close window&lt;/a&gt;
            &lt;input type="hidden" name="status" value="Prospect" /&gt;
            &lt;input type="hidden" name="url_title" value="{url_title}" maxlength="75" /&gt;
            &lt;input type="hidden" name="entry_date" value="&lt;?php echo date("Y-m-d h:i"); ?&gt;" /&gt;
            &lt;input type="hidden" name="allow_comments" value="y" {allow_comments} /&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
{/exp:weblog:entry_form}</pre>
<p>Go ahead and remove the divs we created in step 5, transferring them to your new template group. Then find your &#8220;edit&#8221; link (step 4) and replace it with the following:</p>
<pre>&lt;a onclick="Modalbox.show('{path=modalboxes/edit_prospect}{entry_id}', {title: this.title, width: 800}); return false;" title="{title} &amp;ndash; Edit details" href="#"&gt;</pre>
<p>This line of code passes each weblog entry&#8217;s ID to the &#8220;modalboxes&#8221; template group, where it&#8217;s picked up automatically and used to populate your SAEF.</p>
<p>You can now enjoy modalboxes without cluttering your main templates with hidden divs. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/use-a-modal-box-to-edit-content-inline-with-expressionengine/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Inline editing with ExpressionEngine and AJAX</title>
		<link>http://www.3roadsmedia.com/blog/inline-editing-with-expressionengine-and-ajax/</link>
		<comments>http://www.3roadsmedia.com/blog/inline-editing-with-expressionengine-and-ajax/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 17:53:40 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Developer's Toolbox]]></category>
		<category><![CDATA[Expression Engine]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.3roadsmedia.com/?p=214</guid>
		<description><![CDATA[Web developers are a demanding lot. We&#8217;re impatient for change, we wanted it yesterday, and we love shortcuts. I don&#8217;t mean the &#8220;cutting corners&#8221; type of shortcut. I mean the &#8220;this will make life easier&#8221; type of shortcut. In this post, I&#8217;ll show you how you can use AJAX to edit your ExpressionEngine content on [...]]]></description>
			<content:encoded><![CDATA[<p>Web developers are a demanding lot. We&#8217;re impatient for change, we wanted it yesterday, and we love shortcuts. I don&#8217;t mean the &#8220;cutting corners&#8221; type of shortcut. I mean the &#8220;this will make life easier&#8221; type of shortcut.</p>
<p>In this post, I&#8217;ll show you how you can use AJAX to edit your ExpressionEngine content on the front end, without a page refresh, and with a simple click of the mouse.</p>
<p><strong>NOTE: I recently wrote about an improved method for inline editing with EE using modal boxes. <a href="http://www.3roadsmedia.com/blog/use-a-modal-box-to-edit-content-inline-with-expressionengine/">Read the tutorial here</a>.</strong><span id="more-591"></span></p>
<h3>The Problem</h3>
<p>Making changes to front end content can be time consuming and confusing. Even if your templates are set to display WordPress-style &#8220;edit&#8221; links next to each weblog entry, you have to use the control panel (CP) to make changes. <strong>Many end users don&#8217;t feel comfortable</strong> using the CP, and many times you just want to make a quick change without leaving the front end.</p>
<p>The good news is that with a bit of AJAX, we can bypass the CP altogether, greatly simplifying the editing process.</p>
<h3>The Solution</h3>
<p>I took my inspiration from <a href="http://24ways.org/2005/edit-in-place-with-ajax">an old post on inline editing</a> at 24 ways. I&#8217;ve modified the code to work with ExpressionEngine, and will show you how you can get it to work with your own EE site.</p>
<h4>Step 1: Create a new EE weblog and template</h4>
<p>Create a new weblog and connect it to a custom field group with at least one textarea field (<strong>make sure the formatting is set to &#8220;none&#8221;</strong>). Enter a few sample entries, and then create a new template.</p>
<p>Enter the following HTML in your template, substituting your weblog name for <strong>ajax-test</strong> and your custom field name for <strong>{body}</strong>:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
    &lt;title&gt;Edit-in-Place with Ajax&lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" href="{stylesheet=home/stylesheet}" /&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h1&gt;Editing Inline with ExpressionEngine and AJAX&lt;/h1&gt;

{if logged_in}
    {exp:weblog:entries disable="categories|member_data|pagination|trackbacks" weblog="ajax-test"}
        &lt;h2&gt;{title}&lt;/h2&gt;
        &lt;p&gt;{body}&lt;/p&gt;
    {/exp:weblog:entries}
{/if}

{if logged_out}&lt;p&gt;You must be logged in to view this page!&lt;/p&gt;{/if}
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>I recommend previewing your template to ensure the entries are displaying properly.</p>
<h4>Step 2: Grab the Prototype JavaScript library</h4>
<p>The script we&#8217;ll be using requires Prototype. <a href="http://www.prototypejs.org/download">Get the latest version of Prototype here</a>, upload it to your server, and add the following line to your template (inside the <code>&lt;head&gt;</code> tags):</p>
<pre>&lt;script src="http://path-to-your-scripts-folder/prototype.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<h4>Step 3: Grab the Script</h4>
<p>Here&#8217;s where all the magic happens. <a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/03/editinplace_basic.js">Grab the script here</a> and save it as <strong>editinplace.js</strong> (don&#8217;t upload it just yet). Be sure to place a call to the script in your template by adding this line:</p>
<pre>&lt;script src="http://path-to-your-scripts-folder/editinplace.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>I recommend leaving the script open in another window while you follow along here.</p>
<h4>Step 4: Get familiar with the script</h4>
<p>Let&#8217;s take a closer look at <strong>editinplace.js</strong>. The first line ensures the script won&#8217;t run until the page is fully loaded. The <code>init()</code> function defines which element ID we want to be editable &#8211; in this case, <strong>editTitle</strong>.</p>
<p>The <code>makeEditable()</code> function does three things:</p>
<ol>
<li><strong>On mouseclick</strong>, call the <code>edit()</code> function, which hides the editable text and displays a textarea and two buttons (&#8220;Save&#8221; and &#8220;Cancel&#8221;)</li>
<li><strong>On mouseover</strong>, add a CSS class to the editable area (this allows us to highlight it on hover)</li>
<li><strong>On mouseout</strong>, remove the CSS class from the editable area</li>
</ol>
<p>Notice that the <code>showAsEditable()</code> function is creating and removing a CSS class called <code>editable</code>. You can rename this to whatever you want, but <strong>be sure to add a declaration to your stylesheet</strong>.</p>
<p>The declaration I&#8217;m using on the demo page is:</p>
<pre>.editable { background:#ffffd3; cursor:pointer; }</pre>
<p>If a user clicks &#8220;Cancel,&#8221; the <code>cleanUp()</code> function is called; it clears the textarea and buttons and unhides the original text.</p>
<p>If a user clicks &#8220;Save,&#8221; the <code>saveChanges()</code> function is called; it posts the changes, displays a &#8220;Saving&#8230;&#8221; message, and returns the updated text.</p>
<h4>Step 5: Grab the PHP</h4>
<p>The script you just copied works in tandem with a small PHP script, which takes your changes and echoes them to the screen. Paste the script below into a new file:</p>
<pre>&lt;?php
    $id = $_POST['id'];
    $content = $_POST['content'];
    echo htmlspecialchars($content);
?&gt;</pre>
<p>Save this file as <strong>edit.php </strong>and upload it to your server. Update <strong>editinplace.js</strong> (line 53) to point to your PHP script, then upload this file too.</p>
<h4>Step 6: Put the script to work</h4>
<p>Now that we know what the scripts are doing, let&#8217;s put them to work. Editinplace.js is looking for an element with an ID of <strong>editTitle</strong>, but your template doesn&#8217;t currently have that. Let&#8217;s add it in.</p>
<p>Change the <code>&lt;h2&gt;</code> tag in your template to this:</p>
<pre>&lt;h2 id="editTitle"&gt;{title}&lt;/h2&gt;</pre>
<p>Save your template and preview it. Move your mouse over your <strong>first heading</strong>. Assuming you copied my CSS rules from above, you should see a highlighted box surround your heading, and your cursor should change to a pointer. Click the heading, edit the text, and click &#8220;Save&#8221; or &#8220;Cancel.&#8221;</p>
<p>If you try to edit your other headings, you&#8217;ll notice nothing&#8217;s happening.</p>
<p>Why is this? Remember that an ID is unique to a page, so if you have duplicate IDs, you&#8217;ll get strange results. In this case, <strong>only the first element of a given ID will be editable</strong>.</p>
<p>For most ExpressionEngine applications, you&#8217;ll be looping through a weblog several times, so this approach won&#8217;t work.</p>
<h4>Step 7: Making multiple items on the same page editable</h4>
<p>First, change the <code>init()</code> function in <strong>editinplace.js</strong> to this:</p>
<pre>function init() {
    var max = 50;
    for (var i = 1; i &lt;= max; i++) {
        makeEditable('editTitle_' + i);
    }
}</pre>
<p>Then, in your template, modify your <code>&lt;h2&gt;</code> tag like so:</p>
<pre>&lt;h2 id="editTitle<strong>_{count}</strong>"&gt;{title}&lt;/h2&gt;</pre>
<p>Refresh your template and you should be able to make changes to all of your headings.</p>
<h4>Step 8: Posting changes to your ExpressionEngine database</h4>
<p>Up to this point, we&#8217;ve only been echoing changes back to the screen. Now it&#8217;s time to make those changes permanent by posting them to a database.</p>
<p>The bulk of the work will come in <strong>edit.php</strong>, though before we start making changes to that file, we need to add some things to <strong>editinplace.js</strong>.</p>
<p>Update your <code>saveChanges()</code> function to look like this (changes are in <strong>bold</strong>):</p>
<pre>function saveChanges(obj) {
    var new_content = escape($F(obj.id+'_edit'));

    <strong>obj.preUpdate = obj.innerHTML</strong>
    obj.innerHTML = "Saving…";
    cleanUp(obj, true);

    var success = function(t){editComplete(t, obj);}
    var failure = function(t){editFailed(t, obj);}

    var url = 'http://path-to-your-scripts-folder/edit.php';
    var pars = 'id=' + obj.id + '&amp;content=' + new_content<strong> + '&amp;pre=' + obj.preUpdate</strong>;
    var myAjax = new Ajax.Request(url, {method:'post',
    postBody:pars, onSuccess:success, onFailure:failure});
}</pre>
<p>If you copy and paste from above, don&#8217;t forget to update the path to your PHP file.</p>
<p>Next, update <strong>edit.php</strong> to look like this:</p>
<pre>&lt;?php
    $id = $_POST['id'];
    $content = $_POST['content'];
    <strong>$pre = $_POST['pre'];</strong>
    echo htmlspecialchars($content);

<code><span class="html">    <strong>require_once("path-to-your/include.inc.php")</strong>;

</span></code><strong>    $sql = mysql_query("UPDATE exp_weblog_titles SET title = '$content' WHERE title = '$pre'");

    if(!$sql) {
        echo "&lt;p class='error'&gt;Unable to update the title!&lt;/p&gt;";
    }</strong>
?&gt;</pre>
<p>You&#8217;ll need to create an include file that contains the connection information for your database (<a href="http://www.3roadsmedia.com/wordpress/wp-content/uploads/2009/03/sample-include.inc.txt">grab a sample include file here</a>).</p>
<p>Update the path to your include file, enter your database connection information, save all three files, upload them, and refresh your rendered template. Make some changes to the titles. Refresh the page again, and your changes should remain.</p>
<p>Congratulations &#8211; you&#8217;ve just made a direct change to your EE database with AJAX!</p>
<h3>Going a step further &#8211; editing more than just titles</h3>
<p><del>You probably noticed in the demo that the excerpt for each post was also editable.</del> Here&#8217;s how you do it:</p>
<h4>Step 9: Create another editable element</h4>
<p>First, you&#8217;ll need to tell the script that you want to make another set of IDs editable. Modify the <code>init()</code> function in <strong>editinplace.js</strong> to look like this:</p>
<pre>function init() {
    var max = 50;
    for (var i = 1; i &lt;= max; i++) {
        makeEditable('editTitle_' + i);
        <strong>makeEditable('editBody_' + i);</strong>
    }
}</pre>
<p>Next, modify your template by adding the new ID:</p>
<pre>&lt;p<strong> id="editBody_{count}"</strong>&gt;{body}&lt;/p&gt;</pre>
<p>Finally, to post any changes to your paragraphs to the database, you&#8217;ll need to modify <strong>edit.php</strong>:</p>
<pre>&lt;?php
    $id = $_POST['id'];
    $content = $_POST['content'];
    $pre = $_POST['pre'];
    echo htmlspecialchars($content);

<code><span class="html">    require_once("path-to-your/include.inc.php");</span></code>

<strong>    if(stristr($id, 'Title') == true) {
        $sql = mysql_query("UPDATE exp_weblog_titles SET title = '$content' WHERE title = '$pre'");
    } elseif(stristr($id, 'Body') == true) {
        $sql = mysql_query("UPDATE exp_weblog_data SET field_id_65 = '$content' WHERE field_id_65 = '$pre'");
    }</strong>
?&gt;</pre>
<p>Since the PHP script is handling requests for both <code>editTitle</code> and <code>editBody</code>, we need to use the <code>stristr()</code> function to determine which ID is being passed in.</p>
<p><strong>Be sure that the field ID matches your custom field! </strong>In the example above, it is 65, but yours is likely different.</p>
<p>You can find your field ID by going into the CP, clicking &#8220;Admin,&#8221; selecting &#8220;Custom Weblog Fields,&#8221; and hovering your mouse over the field name on the left. The field ID will appear at the very end of the URL string at the bottom left of your browser.</p>
<h4>Step 10: Provide a textarea for paragraphs and a text input for titles</h4>
<p>You probably don&#8217;t want to be editing large hunks of text in a tiny input box. To get a textarea to show up when you click on a paragraph (while keeping a text input for your titles), modify the <code>edit()</code> function in <strong>editinplace.js</strong>:</p>
<pre>function edit(obj) {
    Element.hide(obj);

<strong>    if(obj.id.search(/Title/) != -1) {
        // show an input box if we're editing a header
        var textbox ='&lt;div class="edit-input" id="' + obj.id + '_editor"&gt;&lt;input name="' + obj.id + '" type="text" id="' + obj.id + '_edit" value="' + obj.innerHTML + '" /&gt;';
    } else {
        // else show a textarea
        var textbox ='&lt;div class="edit-area" id="' + obj.id + '_editor"&gt;&lt;textarea name="' + obj.id + '" id="' + obj.id + '_edit"&gt;' + obj.innerHTML + '"&lt;/textarea&gt;';
    }</strong>

    var button = '&lt;input type="button" value="SAVE" id="' + obj.id + '_save"/&gt; OR &lt;input type="button" value="CANCEL" id="' + obj.id + '_cancel"/&gt;&lt;/div&gt;';

    new Insertion.After(obj, textbox+button);

    Event.observe(obj.id+'_save', 'click', function(){saveChanges(obj)}, false);
    Event.observe(obj.id+'_cancel', 'click', function(){cleanUp(obj)}, false);
}</pre>
<h4>Step 11: Limiting edits to certain member groups</h4>
<p>Before you decide to go crazy with inline editing, remember that, without the proper checks, anyone who visits your site can make changes to your content.</p>
<p>For starters, you should wrap your editable areas in a <code>{if logged_in}</code> conditional. Once that&#8217;s done, you should also consider only allowing certain member groups to edit content inline. Here&#8217;s a quick fix:</p>
<pre>&lt;h2<strong>{if member_group == 1}</strong> id="editTitle_{count}"<strong>{/if}</strong>&gt;{title}&lt;/h2&gt;</pre>
<p>These conditionals allow you to specify who can edit which areas. You could, for example, allow members to edit your body text, but only allow admins to edit your titles.</p>
<h3>Limitations</h3>
<p>While working through this script, I came up against a few roadblocks:</p>
<ul>
<li>When making more than one element (e.g., headers <strong>and </strong>paragraphs) editable, you must have an equal number of each. In other words, if there are 3 headers on the page that you want to edit, you can&#8217;t have more than 3 paragraph blocks that are editable. Paragraphs beyond the 3rd won&#8217;t be clickable.</li>
<li>You have to pre-define a max number of editable fields (in my example, this is 50).</li>
<li>Inline editing doesn&#8217;t work well with headings that are also anchors</li>
</ul>
<h3>Conclusion</h3>
<p>This is my first attempt at getting inline editing to work with ExpressionEngine. I don&#8217;t profess to be a code guru, so it is my hope that a little bit of discussion can help improve the code here and make life easier for developers and end users everywhere.</p>
<p>I welcome your feedback, frustrations, and success stories. Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.3roadsmedia.com/blog/inline-editing-with-expressionengine-and-ajax/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

