Get An Email List of All Authors On Your System

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’s particularly useful on larger installs:

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

And the Authors tag allows for all sorts of cool filtering attributes so you can get at any group of authors in the system, ordered however you like:

  • display_name: Specifies a particular author to select.
  • lastn: Limits the selection of authors to the specified number.
  • sortby: Supported values: displayname, name, created_on.
  • sort_order: Supported values: ascend, descend.
  • roles: comma separated list of values. eg “Author, Commenter”
  • need_entry: 1 | 0 (default is 1)
  • status: Supported values: enabled, disabled. Default is enabled.

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

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

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.

Just make sure you use this for good, not evil.

Upgrading to MT4

Over the last few major version changes, Learning Movable Type has published guides to upgrading safely, without risk of messing up your blog. The most recent tutorial was A Safe Way to Upgrade to MT3.3.

The three main steps that still hold for safely upgrading to MT4 (from MT3) are:

  1. Make a back up of your database.
  2. Make sure all the plugins you use for your site have upgrades that are compatible with the new version.
  3. Install MT into a new directory in your cgi-bin. Do NOT overwrite your existing MT directory.

The Movable Type ProNet community has done a stellar job in outlining everything you need to know to do a successful upgrade to MT4. These instructions can be found at the MT Community Wiki in the Community Generated Upgrade Guide.

Please see the instructions at the Community Wiki for the specific details on how to safely upgrade your MT blog to MT version 4.

Creating a Google Toolbar Button for Your Blog

Creating a custom button for your blog to be used on the Google Toolbar is a great way to promote your blog. Once installed, the button can act as a graphical bookmark to your site. You and your readers can search your site using the search bar in the Google toolbar, without having to be on your site. In fact, you can highlight any text on any web page, click on your custom icon in the browser, and you will perform a search the text you just highlighted on your blog. The custom button can even list your last several entries, with data pulled from your feed.

Google toolbar example

I recently updated my Google toolbar for Simply Recipes and created a new one for a new site, Food Blog Search. (If you want to see the Google Toolbar in action, follow the instructions to add a button on the Food Blog Search site.) Google's instructions for making a custom button can be convoluted and overwhelming. It took me several hours over several days to work out the correct code for the toolbars. So to save any of you similar pain, I'm presenting the steps here.

Step 1: Install Google Toolbar

The Google Toolbar requires using either IE or Firefox for your browser. Go to this page at Google to install it.

Continue Reading »

Template Macros: The coolest template trick you don't know about

Recently when working on updating the Photo Gallery plugin to work with Movable Type 4.1 I found myself neck deep in some of the most complicated Movable Type templates I have ever seen. Of course, their complexity is exactly why the Photo Gallery plugin outputs such beautiful results.

Within these templates I have the need to take an arbitrary image asset of any size, and scale it proportionally to fit inside a well defined area. This could be a thumbnail, or a larger version of the photo at hand. What I found myself doing is replicating the same template code over and over again in order to produce the output I desired throughout the template set. Here is the template code I was using:

<MTSetVarBlock name="width" trim="1"><MTEntryAssets><MTAssetProperty 
    property="image_width"></MTEntryAssets></MTSetVarBlock>
<MTSetVarBlock name="height" trim="1"><MTEntryAssets><MTAssetProperty 
    property="image_height"></MTEntryAssets></MTSetVarBlock>
<mt:if name="width" gt="$height">
    <MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink width="90" 
        regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
<mt:else>
    <MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink height="90" 
        regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
</mt:if>

Yikes.

To complicate things further, each time I cut and pasted this code around I had to modify it slightly depending upon the size of the photo I wanted to output. This presented the following problems:

  • my template code was getting very messy.
  • my template code was getting harder and harder to update because I had the same code in multiple places

What I found myself in need of is something a developer might call a "function" or "macro." In layman's terms, I needed a way to write this template code once, and then to invoke along with a few parameters in order to change its behavior and output as needed.

Luckily, Movable Type has exactly what I needed: a little template tag called MTSetVarTemplate. This template tag allowed me to define just such a macro so that I could reduce all of the complicated template code above into something far simpler:

<MTVar name="photo" max_size="90">

Wow, what an improvement!

Continue Reading »

How to Customize Default Styles in MT4

Okay, so you've created a new blog in MT4. You've followed the system prompts and have picked a style from the available defaults. Now you want to customize the style you've chosen, perhaps use a different font, or a different color for an element. You go to look at the stylesheet template in Design > Templates > Stylesheet, and instead of seeing CSS code to edit, you see this:

lmt-edit-stylesheet.jpg

Now what?

Continue Reading »