<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Posts by Jesse Gardner on Learning Movable Type</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/" />
   <link rel="self" type="application/atom+xml" href="http://www.learningmovabletype.com/contributors/plasticmind/" />
   <id>tag:,2008-02-25:/5</id>
   <updated>2008-04-08T21:52:54Z</updated>
   <subtitle>Tutorials and helpful tips for the Movable Type web publishing system</subtitle>
   <generator uri="http://www.movabletype.org/">Movable Type Publishing Platform 4.01</generator>

<entry>
   <title>Get An Email List of All Authors On Your System</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/email_list_of_all_authors_on_your_system/" />
   <id>tag:www.learningmovabletype.com,2008://5.2125</id>
   
   <published>2008-03-13T17:27:56Z</published>
   <updated>2008-04-08T21:52:54Z</updated>
   
   <summary><![CDATA[This article was first published at Movable Tweak. This little snip of code will dump out a list of all the users and their email addresses on your install in a comma-delimited format that you can easily import into your email client. It&#8217;s particularly useful on larger installs: &lt;mt:Authors include_blogs="all"&gt;...]]></summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="Authors" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Email" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Templates" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="authors" label="Authors" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="email" label="Email" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="templates" label="Templates" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p><em>This article was first published at <a href="http://www.movabletweak.com/templates/email_list_of_all_authors.php">Movable Tweak</a>.</em></p>

<p>This little snip of code will dump out a list of all the users and their email addresses on your install in a comma-delimited format that you can easily import into your email client.  It&#8217;s particularly useful on larger installs:</p>

<pre><code>&lt;mt:Authors include_blogs="all"&gt;
    &lt;mt:IfNonEmpty tag="AuthorEmail"&gt;
        &lt;mt:IfNonEmpty tag="AuthorDisplayName"&gt;"&lt;mt:AuthorDisplayName /&gt;" &lt;/mt:IfNonEmpty&gt;
        &amp;lt;&lt;mt:AuthorEmail /&gt;&amp;gt;,
    &lt;/mt:IfNonEmpty&gt;
&lt;/mt:Authors&gt;
</code></pre>

<p>And the <a href="http://www.movabletype.org/documentation/appendices/tags/authors.html">Authors tag</a> allows for all sorts of cool filtering attributes so you can get at any group of authors in the system, ordered however you like:</p>

<ul>
<li>display_name: Specifies a particular author to select.</li>
<li>lastn: Limits the selection of authors to the specified number.</li>
<li>sort<em>by: Supported values: display</em>name, name, created_on.</li>
<li>sort_order: Supported values: ascend, descend.</li>
<li>roles: comma separated list of values. eg &#8220;Author, Commenter&#8221;</li>
<li>need_entry: 1 | 0 (default is 1)</li>
<li>status: Supported values: enabled, disabled. Default is enabled.</li>
</ul>

<p><strong>Note:</strong> Some people have asked about creating an email list of all the commenters on the system, and it&#8217;s very simple.  The code stays the same, but you just need to specify roles=&#8221;Commenter&#8221; and need_entry=&#8221;0&#8221; (since most commenters won&#8217;t have written an entry).  Here&#8217;s the code to do it:</p>

<pre><code> &lt;mt:Authors include_blogs="all" roles="Commenter" need_entry="0" sort_by="display_name"&gt;&lt;mt:IfNonEmpty tag="AuthorEmail"&gt;&lt;mt:IfNonEmpty tag="AuthorDisplayName"&gt;"&lt;mt:AuthorDisplayName /&gt;" &lt;/mt:IfNonEmpty&gt;&amp;lt;&lt;mt:AuthorEmail /&gt;&amp;gt;, &lt;/mt:IfNonEmpty&gt;
 &lt;/mt:Authors&gt;
</code></pre>

<p>Notice the code is much more compressed than the code given previously.  If you tried the previous code, you probably noticed that the spacing is crazy because of all the hard returns and spaces we have in there.  This second set of code I posted will give you a highly compact list of email addresses than can literally be copied and pasted into an email client.</p>

<p><strong>Just make sure you use this for good, not evil.</strong></p>
]]>
      

   </content>
</entry>

<entry>
   <title>List Random Authors</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/list_random_authors/" />
   <id>tag:www.learningmovabletype.com,2008://5.2040</id>
   
   <published>2008-01-24T06:12:24Z</published>
   <updated>2008-01-24T16:36:46Z</updated>
   
   <summary>As communities grow, so does the need to showcase your authors. Having a hefty community of authors is a great thing (content producers FTW!) but everyone wants their fifteen minutes. This handy little tip can help make sure everyone gets their fair share of the limelight. A couple of things...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="Authors" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="General Tips and Tricks" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Templates" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="authors" label="Authors" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="php" label="PHP" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="randomauthors" label="Random Authors" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p><strong>As communities grow, so does the need to showcase your authors.</strong>  Having a hefty community of authors is a great thing (content producers FTW!) but everyone wants their fifteen minutes.  This handy little tip can help make sure everyone gets their fair share of the limelight.  </p>

<p>A couple of things to note first:  Make sure that you&#8217;ve got author archives set up.  You can hack this to work with author profiles, but that&#8217;s not the scope of this tutorial.  Also, this tutorial assumes that your server is parsing whatever page this is on as PHP.  As a rule of thumb, if your file extension is .html, this probably won&#8217;t work; if you&#8217;re file extension is .php, you should be fine.</p>

<pre><code>&lt;?php
    $displayed_authors = array(); // Will hold indexes from $authors for authors already displayed
    $show = 25; // How many authors should we show?

    &lt;mt:Authors&gt;
        $authors[&lt;mt:AuthorId /&gt;] = '&lt;li&gt;&lt;a href="&lt;mt:EntryLink archive_type="Author" /&gt;"&gt;&lt;mt:EntryAuthorDisplayName encode_php='1' /&gt;&lt;/a&gt;&lt;/li&gt;';
    &lt;/mt:Authors&gt;

    for ($i=1; $i &lt;= $show; $i++) {
        $rn = array_rand($authors); 
        // Loops until it finds an author not displayed
        while(in_array($rn, $displayed_authors)) {
            $rn = array_rand($authors);
        }
        array_push($displayed_authors, $rn);
        echo $authors[$rn];
    }
?&gt;
</code></pre>

<p>First, we set up an array where we&#8217;ll store all the authors that have already been displayed.  More on that in a minute.  Then we define how many authors we want to show with this block.</p>
]]>
      <![CDATA[<p>Next, we loop through all the authors, stashing them all into an array.  Actually, we&#8217;re stashing the html that we want displayed as it gets looped through.  This can be basically whatever you want.  If you use other Movable Type tags, make sure you add the  <code>encode_php='1'</code> filter or else you could get some nasty PHP parse errors and break your site. (<em>Usually because of single quote/double quote mismatching.</em>)</p>

<p>Next up is displaying the authors.  We&#8217;re going to loop through authors 25 times; remember, that&#8217;s what we set up with the $show variable.  The <code>array_rand</code> function basically says &#8220;pull a random number from 1 to the number of items in our array&#8221;.  We had to put in a special <code>while</code> loop to make sure it didn&#8217;t pick a number already used; this would result in duplicate listings of a single author.  The <code>array_push</code> then stores the new, non-duplicate random number in our displayed authors array to ensure we don&#8217;t duplicate it next time through the loop.</p>

<p>Finally, we echo a random item from the <code>$authors</code> array.  This loops through however many times you&#8217;ve told it to with the <code>$show</code> variable.</p>

<p><strong>Note:</strong> If you want to keep a particular user from showing up in your random list, there are a few ways to accomplish this.  The easiest is to put a <code>&lt;mt:SetVarBlock name="displayname"&gt;&lt;mt:AuthorDisplayName /&gt;&lt;/mt:SetVarBlock&gt;</code> just after the opening <code>&lt;mt:Authors&gt;</code> tag.  Then just wrap the code that populates the $authors array in an <code>&lt;mt:Unless&gt;</code> loop, like so: <code>&lt;mt:Unless name="displayname" eq="John Doe"&gt; $authors[&lt;mt:AuthorID /&gt;]... &lt;/mt:Unless&gt;</code>. </p>

<p><strong>Thanks to <a href="http://movalog.com">Arvind</a> for helping me solve the dupe problem.  He also made me say that I will now worship him forever.</strong></p>
]]>
   </content>
</entry>

<entry>
   <title>Rotating Banner Ads in MT Using PHP</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/rotating_banner_ads_mt_style/" />
   <id>tag:www.learningmovabletype.com,2007://5.1825</id>
   
   <published>2007-10-10T06:04:29Z</published>
   <updated>2007-10-17T02:22:09Z</updated>
   
   <summary>(This article is cross posted at MovableTweak.) A client recently asked me if they could have an easy-to-manage banner ad setup, with the ability to add advertisements and specify links and alternate text, while at the same time being able to manage them easily. Sounds like a job for&#8230; Movable...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="General Tips and Tricks" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Images" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="PHP" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="advertising" label="Advertising" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="bannerad" label="Banner Ad" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="php" label="PHP" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="randomimage" label="Random Image" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="rotatingbannerad" label="Rotating Banner Ad" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p>(This article is <a href="http://www.movabletweak.com/templates/rotating_banner_ads_mt_style.php">cross posted at MovableTweak</a>.)</p>

<p>A client recently asked me if they could have an easy-to-manage banner ad setup, with the ability to add advertisements and specify links and alternate text, while at the same time being able to manage them easily.  Sounds like a job for&#8230; Movable Type!</p>

<p>This tip can be used for any ads, or any images for that matter.  There are four basic steps: upload the ad, create an entry for it, create the php file and include it in your template.</p>
]]>
      <![CDATA[<h4>1. Create an Ad Blog</h4>

<p>Create a brand new blog called &#8220;Banner Ads&#8221;; you can call it something else, but you&#8217;ll need to remember it for later, so whatever it is, write it down.</p>

<p>To keep things organized, set your publishing directory to /ads/.  Once you decide on a directory, you&#8217;ll need to make note of it and upload all of the images in your rotation to the same directory.  This isn&#8217;t <em>required</em>, but as we go on you&#8217;ll understand how it can make your job easier.</p>

<p>Go to <strong>Design » Templates</strong> and delete all the templates.  Be sure to get the archive templates and template modules; no sense in having them sitting around taking up space.  We&#8217;ll return to the templates in a moment to create a new template, but first let&#8217;s create and upload our ad.</p>

<h4>2. Upload Image</h4>

<p>You&#8217;ll need to decide what size ads or images you&#8217;ll be using here.  For sake of example, I&#8217;m going to create a banner in Photoshop using a standard banner ad size of 468x60 pixels:</p>

<p><img src="http://www.movabletweak.com/images/car_donate.gif" /></p>

<p>Click <strong>Create &raquo; Upload File</strong> to upload the first image.  Movable Type&#8217;s asset manager will walk you through the upload process.  Once the file is uploaded, make note of its location.  You will create an entry for each image you upload.</p>

<h4>3. Create an Entry for Each Image</h4>

<p>In the title field, give your ad a name.  This is going to be the TITLE text for your banner ad link.  Next we&#8217;re going to use the Body field for your path and file name of your image.  (To do it right, get the Custom Fields plugin and set up an actual Image field.  This saves will save you from headaches down the road.)  This filename can be relative to your site (i.e. /car<em>donate.gif) or a full URI (http://www.plasticmind.com/images/header.jpg) The Keywords field will be the hyperlink (destination) that visitors will be taken to when they click your ad.  This can be relative to your site (i.e. /support/donate</em>your_car.html) or a full URL (i.e. http://www.plasticmind.com/). </p>

<p>Save the entry.  Repeat process for all images you want to appear in the rotation.</p>

<h4>4. The PHP File</h4>

<p>Go to Templates and create a new index template called &#8220;Banner Ads&#8221;  This will be the PHP file that will generate the rotation and we will call to it from our other templates.  Set the output file to &#8220;banner.php&#8221;.  Now let&#8217;s drop the following code into the template, save and rebuild it:</p>

<pre><code>&lt;?php
    &lt;mt:Entries lastn="999"&gt;
        $ad[&lt;mt:EntryId /&gt;]['pic']='&lt;mt:EntryBody strip_linefeeds='1' encode_php='1' /&gt;';    
        $ad[&lt;mt:EntryId /&gt;]['link']='&lt;mt:EntryKeywords strip_linefeeds='1' encode_php='1' /&gt;';    
        $ad[&lt;mt:EntryId /&gt;]['title']='&lt;mt:EntryTitle encode_php='1' /&gt;';
    &lt;/MTEntries&gt;    
    $rn = array_rand($ad);    
    echo '&lt;a href="' . $ad[$rn]['link'] . '" title="' . $ad[$rn]['title'] . '"&gt;';
    echo '&lt;img src="'.$ad[$rn]['pic'] . '" alt="' . $ad[$rn]['title'] . '"&gt;&lt;/a&gt;';
?&gt;
</code></pre>

<p>It looks complicated but isn&#8217;t.  Basically, the <code>&lt;mt:Entries&gt;</code> container will loop through as many banner ad entries you have.  (The lastn attribute is so it looks for the last 999 entries, not the default days.)  For each one it will create a variable ($ad) with an array based on the entry id.  In this array, we&#8217;re storing the &#8216;pic&#8217; (file path), the &#8216;link&#8217; (destination url) and the &#8216;title&#8217; (ad title).  We&#8217;re using the strip_linefeeds=&#8217;1&#8217; attribute when building this to ensure that no stray <code>&lt;p&gt;</code> or <code>&lt;br /&gt;</code> tags get into your image path or your hyperlink.  That causes weird things to happen.</p>

<p>Then we pull a random ad from the array and echo (or print) two lines of code.  The first line is your hyperlink, with the href set to the ad&#8217;s &#8216;link&#8217; (made up of <code>&lt;mt:EntryKeywords /&gt;</code>) and the title set to the ad&#8217;s &#8216;title&#8217; (made up of  <code>&lt;mt:EntryTitle /&gt;</code>).  The next line is the image, with the src set to the ad&#8217;s &#8216;pic&#8217; (the file path stored in <code>&lt;mt:EntryBody /&gt;</code>) and for good measure we&#8217;ve set the alt to <code>&lt;mt:EntryTitle /&gt;</code>.</p>

<p>Save and rebuild the template. You&#8217;re ready to test it.  Type in your domain and the file name you gave it (i.e. http://www.rideforlife.com/banner.php) to see it in action.  You should get a random hyperlinked image.  Almost done.</p>

<h4>5.  Including It In Your Templates</h4>

<p>Wherever you want your rotating banner ad to appear, simply include the banner.php file you created.  The following code is an example:</p>

<pre><code>&lt;div id="bannerad"&gt;
    &lt;?php include '/home/USERNAME/www/banner.php' ?&gt;    
&lt;/div&gt;
</code></pre>

<p>You can pull a full URL in the include, but it&#8217;s much slower and causes considerably more work for the server.  Best to include the full site path to your file.</p>

<p>Rebuild and test it out.</p>

<h4>Troubleshooting</h4>

<p>Something wrong?  </p>

<p>If you ran your banner.php on its own and didn&#8217;t work, you probably aren&#8217;t running php.  Sorry, this solution isn&#8217;t for you.  Probably best to type &#8216;server side includes&#8217; in Google and try your luck there.</p>

<p>If you ran banner.php on its own and it did work, but it&#8217;s not working in your template, you may have called to it incorrectly.  If the php code itself is being displayed instead of the image, your server isn&#8217;t executing the php, and you need to read about <a href="http://www.movabletweak.com/templates/a_more_graceful_template_modul.php">my solution for that on this post</a>.</p>

<p>Not sure what your site path is?  Well, MT has a tag for that. <code>&lt;mt:BlogSitePath /&gt;</code> or you can just look in your Publishing settings&#8230; it&#8217;s listed there as well.</p>
]]>
   </content>
</entry>

<entry>
   <title>10 Reasons MT 4 Will Rock Your Blog</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/187410_reasons_mt_4/" />
   <id>tag:learning.movabletype.org,2007://5.1613</id>
   
   <published>2007-06-05T19:07:13Z</published>
   <updated>2007-10-05T20:41:42Z</updated>
   
   <summary>It was 5 am, and I was headed off to bed after pulling an all-nighter on a client&apos;s project; and who of all people writes me, but Arvind sending over the news that MT 4 beta has just gone public. I couldn&apos;t let this one go without saying something. While...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="Announcements" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="mt4" label="MT4" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p>It was 5 am, and I was headed off to bed after pulling an all-nighter on a client's project; and who of all people writes me, but Arvind sending over the news that MT 4 beta has just gone public.  I couldn't let this one go without saying something.  While it's by no means the perfect content management system, I personally think it's one of the most powerful out-of-the-box blogging packages out there.</p>

<p>So, I came up with a list of ten ways the new Movable Type will rock your blog:</p>]]>
      <![CDATA[<p>1.  <strong>Simple install.</strong>  No, no, really.  The hardest part of installing MT will be uploading the files to your server.  Now, when you run MT for the first time, it walks you through setting up your database, your first user and even LDAP support (if you're running Enterprise).  None of this "Edit your mt-config.cgi, adding blah-blah-blah", ad nauseum.</p>

<p>2.  <strong>Brand New Dashboard.</strong>  A slick new UI, a much more intuitive context switcher and all of your pertinent information right there to greet you when you first log in.  There's even more flash-based blog reporting to come (a la Google Analytics) in upcoming releases.</p>

<p>3.  <strong>Built in WYSIWYG.</strong>  Oh, and I'm not talking about those crappy WYSIWYG editors that create tag soup.  Six Apart took all the good things they learned from the user interface in Vox and brought them to Movable Type.  For instance, if an entry goes long, you don't have to copy and paste to another "Extended Entry" field.  Simply drag the divider line between the entry and the extension.</p>

<p>4.  <strong>Love Your Assets. </strong> File management has been the bane of most web apps.  But the new Asset Manager makes keeping track of what you've uploaded really simple and using what you've got up on your blog even simpler.</p>

<p>5.  <strong>Community Revival.</strong>  There are some amazing things happening in the MT community, not the least of which is a brand new MovableType.org.  I can't say too much about it yet, except to say that contributing to every part of the community will be so much easier and the machanics of updating things like new plugins, new themes, new tutorials, ad infinitum will be automated.  Simply put, there's solid roots beneath all this beta buzz.</p>

<p>6.  <strong>Simple Plugin Development.</strong>  Now, I can't say much about this firsthand.  Those who know me know that they don't want to meet me in a dark alley with Photoshop, but I couldn't develop my way out of an distributive array.  But for all the times Arvind shouted for joy on IM (you know, capital letters), I got a pretty good sense that he was a happy developer.  He also sent me over  code from a redux of one of his most complex plugins, and it was so short and simple that I GOT it.  What's even cooler about MT 4 is that not only are plugins easy to develop, but they've introduced "Components".  Components are plugins only bigger; they change deeper levels of the application itself and don't get turned off or on.  So for instance, before, MT Enterprise was basically a fork of the MT code.  You had MT 3.35 and the MT Enterprise 1.5.  But now, all the enterprise stuff is sold as a Component for MT4.  It makes perfect sense.  Let the enterprises pay for the components while still keeping the MT base relevant (and free!) for the little people.</p>

<p>7.  <strong>Theme Packs.</strong>  Ok, so this isn't coming out in 4.0, but it's been slated for a 4.1 release, so I'm going to get a head start on anticipation.  Right now, StyleCatcher only allows you to package up images and CSS files to apply to your blog.  This was a major pain when we ran The Style Contest because what if someone wanted to offer a theme that featured a horizontal nav bar with an about page?  Well, the default templates were the default templates.  But Theme Packs will change all of that.  Now, as an MT designer, I'm not relegated to template boredom.  I can create my own packs of templates, complete with stylesheets, archive setups and index template customizations; then I can share it!  Better still, as a freelance designer, I can create a library of Theme Packs suited for different customer needs that I can install instead of needing to customize the templates each time.  Lots of potential there.  There's another revolutionary feature slated for 4.1 that will further loose MT from the bonds of a common blogging platform, but my lips are sealed.</p>

<p>8.  <strong>True Community Blogging.</strong>  Blogs used to be about individual expression, but more and more we're starting to understand the need for community.  Movable Type gives the freedom of true community cooperation.  It's had multiple user support for a while now, but MT 4 allows you to create author profile pages and display information relevant to that particular author.  The Enterprise component goes one step further and gives you the ability to create groups and assign them highly specific roles, making workflow headaches a thing of the past.</p>

<p>9.  <strong>Infinitely Customizable Back End.</strong>  The Movable Type app structure used to be powered by HTML::Template, which was a real pain to customize because it required you to master a whole new language set to make any detailed changes.  Even learning to create Transformer plugins was not for the faint of heart.  Now, however, the back end is powered by the same templating language that your blog is using, so customizing your MT app is as simple as tweaking your blog!  And better yet, the plugins that are available to your blog are now available to the application as it generates your interface. This makes me dizzy just thinking about the possibilities.</p>

<p>10.  <strong>It's Open Source! </strong> This will make your blog feel so much happier, improve it's self-image and ultimately love itself again.</p>

<p>Go ahead, try it out.  You can pick it up at <a href="http://www.movabletype.org/download.html">movabletype.org</a>.</p>]]>
   </content>
</entry>

<entry>
   <title>Movable Type Firefox Shortcut</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/001869firefox_shortcut/" />
   <id>tag:www.learningmovabletype.com,2007://10.1869</id>
   
   <published>2007-03-29T19:42:31Z</published>
   <updated>2007-06-26T05:36:58Z</updated>
   
   <summary>I&apos;m constantly bringing up different client&apos;s Movable Type installs for maintenance, and typing out the full path to Movable Type gets old quick. If you install MT to a consistent location (/cgi-bin/mt/mt.cgi) as I do, I&apos;ve got a little Firefox shortcut that will make your life easier. In Firefox, go...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="General Tips and Tricks" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="blogmaintenance" label="Blog Maintenance" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p>I'm constantly bringing up different client's Movable Type installs for maintenance, and typing out the full path to Movable Type gets old quick.  If you install MT to a consistent location (/cgi-bin/mt/mt.cgi) as I do, I've got a little Firefox shortcut that will make your life easier.</p>

<p>In Firefox, go to the bookmark management/organization section.  Create a new bookmark.<br />
<pre><code><br />
Name: <strong>Movable Type</strong><br />
Location: <strong>http://%s/cgi-bin/mt/mt.cgi</strong><br />
Keyword: <strong>mt</strong><br />
</code></pre></p>

<p>Now just type 'mt yourclientsite.com' and Firefox does the heavy lifting.  If you want a FastCGI rendition, just create another bookmark with mt.fcgi and set the keyword to 'mtf'.  It's totally flexible, just put in your standard installation location and you're off!</p>]]>
      
   </content>
</entry>

<entry>
   <title>Helping MT and Images Get Along Nicely</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/001585images_and_movable_type/" />
   <id>tag:www.learningmovabletype.com,2007://10.1585</id>
   
   <published>2007-01-31T05:36:44Z</published>
   <updated>2007-06-26T05:36:59Z</updated>
   
   <summary>By LMT contributor Jesse Gardner of PlasticMind Design and Movable Tweak. This article was also posted on Movable Tweak. Unfortunately, trying to create a photo album with Movable Type is less than simple. Integrating photos into your blog feels like the days when dinosaurs roamed the earth. One great solution...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="Images" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="imagemagick" label="Image::Magick" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="images" label="Images" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="mtembedimage" label="MTEmbedImage" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="photogallery" label="Photo Gallery" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="rightfields" label="RightFields" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="slideshowpro" label="SlideShowPro" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p><em>By LMT contributor Jesse Gardner of <a href="http://www.plasticmind.com">PlasticMind Design</a> and <a href="http://www.movabletweak.com">Movable Tweak</a>. This article was also posted on <a href="http://www.movabletweak.com">Movable Tweak</a>.</em></p>

<p><br />
Unfortunately, trying to create a photo album with Movable Type is less than simple.  Integrating photos into your blog feels like the days when dinosaurs roamed the earth.  One great solution is Byrne's <a href="http://www.majordojo.com/projects/photogallery.php">Photo Gallery Plugin</a>, but that's more of an 'out of the box' solution.  Here we'll walk you through some extremely useful techniques that give you complete control over what happens to your images and how Movable Type spits them out.</p>]]>
      <![CDATA[<h3>Ingredients:</h3>

<p>What you need to make the magic happen:</p>

<ul>
	<li><a href="http://www.staggernation.com/mtplugins/RightFields/">RightFields</a></li>
	<li><a href="http://www.bradchoate.com/weblog/2002/08/07/mtembedimage">MTEmbedImage</a></li>
	<li><a href="http://cpan.uwinnipeg.ca/module/Image::Magick">Image::Magick</a></li>
	<li><a href="http://www.slideshowpro.net/">SlideshowPro</a> (optional for Flash slidedow)</li>
</ul>

<h3>The Concept</h3>

<p>Let's first discuss what will be happening before we actually get started.  </p>

<p>First, we're going set up <a href="http://www.staggernation.com/mtplugins/RightFields/">RightFields</a> to allow photo uploads directly from the new entry screen, eliminating the need for the upload file popup.  We'll also be able to customize the fields specifically for our photos: photo title, photo caption, etc.  One of the frustrating things about <a href="http://www.staggernation.com/mtplugins/RightFields/">RightFields</a> is it's lack of ability to create thumbnails.  Once the photo is added to the entry, the automation magic is all handled by MTEmbedImage, a poorly documented but amazing little gem of a plugin by Brad Choate.  MTEmbedImage lets us specify a thumbnail size in our templates and then generates the thumbnail to spec via Image::Magick (if it doesn't already exist on the server).  We can then use the thumbnail wherever in our templates we'd like.</p>

<p>The final touch is then setting up MT to publish an XML file containing all the photos, captions and links that <a href="http://www.slideshowpro.net/">SlideshowPro</a> can parse.  The end result is a complete local slideshow solution with panache comparable to Flickr.</p>

<h3>Step 1: <a href="http://www.staggernation.com/mtplugins/RightFields/">RightFields</a></h3>

<p>Our first order of business is setting up <a href="http://www.staggernation.com/mtplugins/RightFields/">RightFields</a> to make adding photos simple.  The instructions for RightFields are well written, so you shouldn't have much problem installing and setting it up.  Once you've got RightFields installed, simply go to the 'New Entry' screen and choose "RightFields settings: Standard Fields" at the very bottom of the page.  This will let you customize the standard fields to fit our photo album needs.</p>

<p>(Note: You can also do this with RightFields Extra Fields settings, but Kevin's documented it well enough to figure that part out on your own.) </p>

<p>Let's change the Title field to "Photo Title", the Entry Body field to "Photo Caption" and finally, the Keywords field to "Photo File".  Make sure you keep the type the same for the first two, but for the Photo File we're going to change the type to "File".  Several options will appear:</p>

<p><strong>Upload path<br />
</strong> - This is the "site path" where you want the files uploaded.  (i.e. /home/username/public_html/photos/)  If you're not sure what this is, check out your Site Root under Settings &raquo; Publishing.  It's a good idea to make this a subdirectory (i.e. /photos/) so that all your uploaded photos don't get dumped into your site root; this makes maintenance later on much easier.<br />
<strong>URL path</strong> - This is the full url of the directory where your files are uploaded.  (i.e. http://www.mydomain.com/photos/)  Again, a quick glance at your publishing settings will give you the starting point.<br />
<strong>Filenames</strong> - Keep, dirify, id or basename; Keep leaves the name of the file you've chosen as is, dirify applies the standard MT dirification routines to it, id changes the name to the entry id number and basename uses the entry basename.  I prefer to keep it as close as possible to the name I've chosen, so I'm going to suggest dirify.<br />
<strong>Overwrite</strong> - Self-explanatory; to reduce confusion I usually check this box.</p>

<p>Once you've make these changes, click "Save Changes".</p>

<p>(Note: RightFields appends each filename with the name of the field it was uploaded to in order to avoid naming conflicts.  Don't worry about it.)</p>

<h3>Step 2: <a href="http://www.bradchoate.com/weblog/2002/08/07/mtembedimage">MTEmbedImage</a></h3>

<p>This part is the most crucial yet most difficult part, because the documentation on the <a href="http://www.bradchoate.com/weblog/2002/08/07/mtembedimage">MTEmbedImage</a> is sparse and it doesn't break with any usefull error messages, it just returns an empty spot in your file where the code was.  So be sure that you follow this part carefully; also, make sure you've got Image::Magick installed on your server (you can run mt-check.cgi to find out) or else you're just wasting your time reading this.</p>

<p>Let's start simple.  We'll create a stripped down block of code that you can put in any MTEntries container.  Here's the code:</p>

<p><code>&lt;div class=&quot;entry&quot;&gt;<br />
	&lt;h3&gt;&lt;a href=&quot;&lt;$MTEntryPermalink$&gt;&quot;&gt;&lt;$MTEntryTitle$&gt;&lt;/a&gt;&lt;/h3&gt;<br />
	&lt;div class=&quot;entry-photo&quot;&gt;<br />
		&lt;MTEmbedImage basename=&quot;[MTBlogName]photos/[MTEntryKeywords]&quot; width=&quot;425&quot; thumbsuffix=&quot;-425&quot;&gt;<br />
		&lt;img src=&quot;&lt;$MTEmbedImageThumbFilename$&gt;&quot; alt=&quot;&lt;$MTEntryTitle$&gt;&quot; /&gt;<br />
		&lt;/MTEmbedImage&gt;<br />
	&lt;/div&gt;<br />
	&lt;$MTEntryBody$&gt;<br />
&lt;/div&gt;</code></p>

<p>Let's look at what's happening here.  Everything's wrapped in an .entry div, and our entry title is placed in an h3.  Now we place our photo; we'll put it in a .entry-photo div for greater flexibility.  We open the MTEmbedImage tag with some important attributes: basename sets the file naming convention for our thumbnail.  In this example, we're telling the plugin that all thumbnails are to be placed in the photos directory and should be named using the MTEntryKeywords field.  The width attribute specifies the width to resize it to.  Setting only one dimension will cause it to resize to that measurement while keeping correct proportions.  Finally, the thumbsuffix is appended to the thumbnail after creation.  (Note: If a file already exists with this name, the plugin will just serve up the image, not recreate it.)  Finally, we put the caption (MTEntryBody) right below the picture.</p>

<p>Now, let's say you want to get a bit more complex and link the thumbnail to the original sized version of your image.  You could always put the thumbnail on the index and the original size on the individual entry archive using the pattern above.  But let's link directly to the original.  This is where remembering your setup becomes vital.  I'm just editing the code between my MTEmbedImage tags:</p>

<p><code>&lt;a href=&quot;&lt;$MTBlogURL$&gt;photos/&lt;$MTEntryKeywords$&gt;&quot; title=&quot;Full Image&quot;&gt;<br />
		&lt;img src=&quot;&lt;$MTEmbedImageThumbFilename$&gt;&quot; alt=&quot;&lt;$MTEntryTitle$&gt;&quot; /&gt;<br />
		&lt;/a&gt;</code></p>

<p>What's different here?  I've added an anchor and recreated my photo location here.  The original photo got uploaded to the photos directory (remember I specified that in the RightFields settings?) and it's name is stored in the Keywords field, so I'm simply linking the thumbnail to the full version.  If you'd like it to pop open a new window (though it's a bit of a faux pas) just add target="_blank" to your anchor.</p>

<p>I've also created sample code for placing a thumbnail like this in the default Movable Type template (this goes between the MTEntries tag).  You can find it here.</p>

<h3>Step 3: <a href="http://www.slideshowpro.net/">SlideshowPro</a></h3>

<p>So far, we've managed to get MT creating thumbnails and placing them inside the default templates.  Let's take this power another step further and integrate it with one of the more powerful Flash-based slideshow programs out there, <a href="http://www.slideshowpro.net/">SlideshowPro</a>.  (The same principles should apply for other slideshow programs as well, comments are welcome.)</p>

<p>Essentially SlideShowPro pulls in an XML feed to find out all the information about the pictures; fortunately, MT can publish XML, no sweat.  Be aware that you do need Flash to configure SlideShowPro; the location of the XML file as well as look-and-feel customization are all set up in Flash.  But the specific picture information is fed to SlideShowPro via XML.  Here's an example of a full XML SlideShowPro image feed template for Movable Type:</p>

<p><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;gallery&gt;<br />
	&lt;MTCategories&gt;<br />
	&lt;album title=&quot;&lt;$MTCategoryLabel encode_xml=&apos;1&apos;$&gt;&quot; description=&quot;&lt;$MTCategoryDescription encode_xml=&apos;1&apos;$&gt;&quot; lgPath=&quot;/photos/images/&quot;&gt;<br />
		&lt;MTEntries lastn=&quot;9999&quot;&gt;<br />
			&lt;MTEmbedImage basename=&quot;[MTBlogName]photos/[MTEntryKeywords]&quot; width=&quot;425&quot; thumbsuffix=&quot;-425&quot;&gt;<br />
			&lt;img src=&quot;&lt;$MTEmbedImageThumbFilename$&gt;&quot; link=&quot;&lt;$MTEntryPermalink encode_xml=&quot;1&quot;$&gt;&quot; target=&quot;_self&quot; title=&quot;&lt;$MTEntryTitle encode_xml=&apos;1&apos;$&gt;&quot; caption=&quot;&lt;$MTEntryBody encode_xml=&apos;1&apos;$&gt;&quot; /&gt;<br />
			&lt;/MTEmbedImage&gt;<br />
		&lt;/MTEntries&gt;<br />
	&lt;/album&gt;<br />
	&lt;/MTCategories&gt;<br />
&lt;/gallery&gt;</code></p>

<p>The syntax is specific to SlideShowPro, but it's fairly straightforward.  Our MT categories become our SlideShowPro albums (with MT filling in the label and description).  Then we loop through our individual entries and pass on vital information to SlideShowPro through the specialized XML attributes for the img tag (link, target, title, caption).  You could choose to use the full-size photos in your slideshow, but since the slideshow isn't usually displayed more than 600px wide on any given site, it's usually just counterproductive and takes far longer to load.</p>

<p>If you'd like to use thumbnails, simply change the code that appears within the MTEntries tag to the following:<br />
			<br />
			<code>&lt;img src=&quot;&lt;MTEmbedImage basename=&quot;[MTBlogName]photos/[MTEntryKeywords]&quot; width=&quot;425&quot; thumbsuffix=&quot;-425&quot;&gt;&lt;$MTEmbedImageThumbFilename$&gt;&lt;/MTEmbedImage&gt;&quot; link=&quot;&lt;$MTEntryPermalink encode_xml=&quot;1&quot;$&gt;&quot; target=&quot;_self&quot; title=&quot;&lt;$MTEntryTitle encode_xml=&apos;1&apos;$&gt;&quot; caption=&quot;&lt;$MTEntryBody encode_xml=&apos;1&apos;$&gt;&quot; tn=&quot;&lt;MTEmbedImage basename=&quot;[MTBlogName]photos/[MTEntryKeywords]&quot; width=&quot;50&quot; thumbsuffix=&quot;-50&quot;&gt;&lt;$MTEmbedImageThumbFilename$&gt;&lt;/MTEmbedImage&gt;&quot; /&gt;</code><br />
			<br />
It's long and seems convoluted, but it's basically generating 425px wide images for the main display and 50px wide images for your thumbnail display.  It requires a considerable amount of resources on save, but it's generally worth the enhanced experience for your users.</p>

<h3>Step Four: ???</h3>

<p>There are many, many more things you can do with this powerful thumbnail capability.  You could create a masthead photo for your blog and then use conditionals to place it only when the field isn't empty.  You could create multiple views for a product you're selling online without having to create 4 different images.  You could allow users to upload background images and have MT populate the style sheet for true design flexibility.  The sky's the limit.    </p>

<p>We just scratched the surface here, but I think we've covered enough basics here to at least get you off in the right direction.  Please feel free to share your experiences in the comments.</p>]]>
   </content>
</entry>

<entry>
   <title>Dynamic Comment Previewing</title>
   <link rel="alternate" type="text/html" href="http://www.learningmovabletype.com/a/001583dynamic_comment_preview/" />
   <id>tag:www.learningmovabletype.com,2006://10.1583</id>
   
   <published>2006-08-23T15:42:46Z</published>
   <updated>2007-06-26T05:36:59Z</updated>
   
   <summary>By LMT contributor Jesse Gardner of PlasticMind and Movable Tweak. Article double posted at Movable Tweak I&apos;ve never liked the idea of a separate comment preview page. Besides being overkill, it often gets missed during upgrades and becomes just another bug to squash. So after picking up some good ideas...</summary>
   <author>
      <name>Jesse Gardner</name>
      <uri>http://www.movabletweak.com</uri>
   </author>
   
      <category term="Comments and Trackbacks" scheme="http://www.sixapart.com/ns/types#category" />
   
   <category term="comments" label="Comments" scheme="http://www.sixapart.com/ns/types#tag" />
   <category term="javascript" label="Javascript" scheme="http://www.sixapart.com/ns/types#tag" />
   
   <content type="html" xml:lang="en" xml:base="http://www.learningmovabletype.com/">
      <![CDATA[<p><em>By LMT contributor Jesse Gardner of <a href="http://www.plasticmind.com">PlasticMind</a> and <a href="http://www.movabletweak.com">Movable Tweak</a>.  Article double posted at <a href="http://www.movabletweak.com">Movable Tweak</a></em></p>

<p>I've never liked the idea of a separate comment preview page.  Besides being overkill, it often gets missed during upgrades and becomes just another bug to squash.</p>

<p>So after picking up some good ideas from <a href="http://www.mikeindustries.com/">Mike Industries</a>, I decided to toss it to the curb and show our commenters just exactly what their comment will look like <em>as they type</em>.</p>]]>
      <![CDATA[<p>I give you, dynamic comment previewing in three easy steps:</p>

<h3>Step 1: Modify mt-site.js</h3>

<p>Add the following code to the end of your mt-site.js and rebuild it:</p>

<p><code>// Dynamic Comment Preview - Kudos to Mike Industries for the inspiration!<br />
// D.C.P. - Comment Text<br />
function ReloadTextDiv() {<br />
	document.getElementById('TextDisplay').innerHTML = '&lt;p&gt;'+document.getElementById('comment-text').value.replace(/(\r\n|\n)/g,'&lt;br /&gt;').replace(/(&lt;br \/&gt;){2,}/gi,'&lt;'+'/p&gt;&lt;p&gt;')+'&lt;'+'/p&gt;';<br />
}<br />
// D.C.P. - Comment Author<br />
function ReloadNameDiv() {<br />
document.getElementById('NameDisplay').innerHTML = document.comments_form.comment-author.value;<br />
}<br />
// End Dynamic Comment Preview</code></p>

<p>This is the javascript that powers the live comment preview.  Our comment form will call to these functions while you're typing in the author field or the comment field and update the comment preview in realtime.</p>

<h3>Step 2: Modify individual entry archives</h3>

<p>We're now going to add the live preview &quot;box&quot; to your site.  Provided here is the HTML that will work with the standard Movable Type templates.  This should come directly after the closing &lt;/form&gt; tag of your comment form.</p>

<p><code>...&lt;/form&gt;<br />
&lt;div class=&quot;comments-content&quot; id=&quot;preview&quot;&gt;<br />
	&lt;h3 class=&quot;comments-preview&quot;&gt;Comment Preview&lt;/h3&gt;<br />
	&lt;div class=&quot;comment&quot;&gt;<br />
		&lt;div id=&quot;TextDisplay&quot;&gt;&lt;/div&gt;<br />
		&lt;p class=&quot;comment-footer&quot;&gt;Posted by: <br />
			&lt;span class=&quot;author&quot;&gt;&lt;a href=&quot;#&quot; id=&quot;NameDisplay&quot;&gt;<br />
				&lt;script language=&quot;Javascript&quot; type=&quot;text/javascript&quot;&gt;<br />
				&lt;!--<br />
				var authname = getCookie(&quot;mtcmtauth&quot;); <br />
				document.write(authname);<br />
				//--&gt;<br />
				&lt;/script&gt;<br />
			&lt;/a&gt;<br />
                    &lt;/span&gt;<br />
		&lt;/p&gt;<br />
	&lt;/div&gt;<br />
&lt;/div&gt;</code></p>

<p>You may need to modify the structure to fit your own style.  Essentially, whatever element has the id &quot;TextDisplay&quot; will be filled with the comment text and whatever element has the id &quot;NameDisplay&quot; gets filled with the author name.</p>

<h3>Step 3: Modify IEA's once more</h3>

<p>We need to &quot;activate&quot; our form fields, or set them up to call to the D.C.P. javascript we put in mt-site.js earlier.  Simply find the comment author field and add a call to the name reload function onkeyup.  It should look something like:</p>

<p><code>&lt;input id=&quot;comment-author&quot; name=&quot;author&quot; size=&quot;30&quot; onkeyup=&quot;ReloadNameDiv();&quot; /&gt;</code></p>

<p>Let's do the same thing for our comment text field.  This time we're calling to the text reload function.</p>

<p><code>&lt;textarea id=&quot;comment-text&quot; name=&quot;text&quot; rows=&quot;10&quot; cols=&quot;30&quot; onkeyup=&quot;ReloadTextDiv();&quot;&gt;&lt;/textarea&gt;</code></p>

<p>Just be sure that the id's you use on there form elements match the id's in your mt-site.js or else you wont get any updating.</p>

<p>And finally, the moment we've all been waiting for.  Remove the preview button from your template.  It looks something like this: </p>

<p><code>&lt;input type=&quot;submit&quot; accesskey=&quot;v&quot; name=&quot;preview&quot; id=&quot;comment-preview&quot; value=&quot;Preview&quot; /&gt;</code></p>

<p>Rebuild and give it a try.  Gives commenting a whole new 'zing', doesn't it?</p>]]>
   </content>
</entry>

</feed>


