Will be back soon

I havent been posting much recently because I've been extremely busy with various projects including developing and migrating many blogs to WordPress for Adobe.

However, the good news is, Im almost done, and will be posting more regularly and updating a couple of plugins that Ive published in WordPress's plugin directory.

I'll be addressing issues and questions users are having with my plugins shortly, and thanks for those who have been patient with updates. I'll be back soon!

Monthly archive list by year in Movable Type

How to create a Monthly Archive template that is split up by each year with Movable Type's archive template.

The final result would look something like this:

Here's the code:

<mt:ArchiveList type="Yearly" sort_order="descend">
<mt:ArchiveList type="Monthly" sort_order="ascend">
<$mt:ArchiveDate format="%m%Y" setvar="monthYear"$>
<mt:SetVarBlock name="links_{$monthYear}"><li><a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%B"$></a></li></mt:SetVarBlock>
</mt:ArchiveList>
</mt:ArchiveList>

<mt:ArchiveList type="Yearly" sort_order="descend">
     <mt:ArchiveListHeader>
         <ul class="archive-year">
     </mt:ArchiveListHeader>
     <$mt:ArchiveDate format="%Y" setvar="year"$>
          <li><$mt:ArchiveDate format="%Y"$>
               <ul class="archive-month">
               <mt:For var="month" from="1" to="12">
                    <mt:SetVarBlock name="monthYear"><$mt:Var name="month" sprintf="%02d"$><$mt:Var name="year"$></mt:SetVarBlock>
                    <$mt:Var name="links_{$monthYear}" setvar="month_link"$>
                    <mt:If name="month_link">
                         <$mt:Var name="month_link"$>
                    <mt:Else>
                         <li></li>
                    </mt:If>
               </mt:For>
               </li>
           <div style="clear:both;"></div>
           </ul>
     <mt:ArchiveListFooter>
          </ul>
     </mt:ArchiveListFooter>
</mt:ArchiveList>

Then add some styles in your stylesheet for the ul list:

ul.archive-year li {
     list-style:none;
}
ul.archive-year ul li {
     float:left;
     padding:5px;
}

Notice in the above example, there is a blank space if there are no entries in a specific month. If you want a list that does not show gaps for empty months, in the code above, just remove the <li></li> in the <mt:Else> tag:

                    <$mt:Var name="month_link"$>
                    <mt:Else>
                         <li></li> <-- delete this line
                    </mt:If>

Lastly, if you want all the months to show, even if they are empty. You can add this above the template code:

<mt:SetHashVar name="month_text">
    <$mt:Var name="1" value="January"$>
    <$mt:Var name="2" value="February"$>
    <$mt:Var name="3" value="March"$>
    <$mt:Var name="4" value="April"$>
    <$mt:Var name="5" value="May"$>
    <$mt:Var name="6" value="June"$>
    <$mt:Var name="7" value="July"$>
    <$mt:Var name="8" value="August"$>
    <$mt:Var name="9" value="September"$>
    <$mt:Var name="10" value="October"$>
    <$mt:Var name="11" value="November"$>
    <$mt:Var name="12" value="Dececember"$>
</mt:SetHashVar>

And then, in the <mt:Else>, put this:

                    <$mt:Var name="month_link"$>
                    <mt:Else>
                         <li><$mt:Var name="month_text{$month}"$></li>
                    </mt:If>

Top Contributors plugin for WordPress

Top Contributors is a WordPress plugin that lists your top commenters on your blog.

Give your loyal visitors and contributors some recognition by adding a list of your top commenters to your sidebar.
If you dont have a theme that supports widgets, you can display the list anywhere on your blog by adding this code to your template:

<?php if(function_exists('jme_top_contributors')) { jme_top_contributors(); } ?>

Features include:

  • List your top commenters with the option to display their Gravatar, and several other options.
  • Choose from 2 formats of the top commenter list, with complete control of styles via css.
  • Exclude Blog Authors from the top comment list.
  • The list uses a cache system for improved performance. List updates only when a comment status is changed, settings updated, comment deleted or a new comment is added.

Special Feature: Add a special Icon next to each of your Top Commenter's name in their comments to give them a little special recognition for being a regular contributor.

Download

Download Top Contributors

Installation

  1. Download and extract top-contributors.zip file.
  2. Upload the folder containing the Plugin files to your WordPress Plugins folder (usually ../wp-content/plugins/ folder).
  3. Activate the Plugin via the 'Plugins' menu in WordPress.
  4. Go to "Settings > Top Contributors" page to set your options and add the widget.

Screenshots

Other Notes

This is my initial release of this plugin. If there are any bugs or problems you encounter using the plugin, or have suggestions or ideas to improve, please let me know! Thanks.

Easy Multi-page Entry pagination for Movable Type

Movable Type 4.3 offers pagination for various archive pages, however one feature which has not been added is pagination for single entries.

Lets say you have a very long entry that you want broken up into 2, 3 or more pages, there's currently no support for that other than a plugin, such as Pagination from MT Hacks. While that plugin has support for multi-page entries, it also includes a lot of 'extra stuff' and displays the additional pages via dynamic page loads.

If you are looking for something small and easy to create multi-page entries, it can be done with just a little PHP in your Entry archive template.

All you need for this to work is,

  1. Entry pages with PHP extension, or other extension that's parsed by PHP.
  2. Static publishing – will not work with dynamic publishing of entries.

If you already have a blog using .html extensions and don't want to change your links, here's a quick tutorial on how to parse .html with PHP.

Benefits of this method:

  1. Allows for an unlimited amount of pages per entry.
  2. Does not increase the publishing duration of your posts.
  3. Works with all versions of Movable Type, and upgrading will not affect it.
  4. No hassles with plugins, upgrades or MT modifications.
  5. Uses virtually no extra server resources and does not slow page loads.

Open the Entry Archive template, and find the MT tag <$mt:EntryBody$>. If you can't find it, it may be in an included template module.

Here's the PHP code to replace that tag:

<?php
$entrytext = <<<EOF
<$mt:EntryBody$>
EOF;

Basically what this does is put your entry text into a PHP variable which we can manipulate and display in parts.
Now we can split the entry into parts with:

$parts = explode("<!--more-->", $entrytext);

In this case we're using <!--more--> to split the text. I'm using that as the example because it's the same divider used by WordPress, so if you happen to be importing content from WordPress, you would still be able to keep your pagination breaks.

So, for each page you want in your entry, you can just add <!--more--> tag into your entry.

Now we get the current page, and determine which part of the text to display:

$currentPage = (isset($_GET['p'])) ? $_GET['p'] : 1;
$currentPart = $currentPage - 1;

Then we can display the content part based on the page:

echo $parts[$currentPart]; 

The last part is adding the pagination links to next and previous pages:

if ( $currentPage > 1 ) {
     $prev = $currentPage - 1;
     echo '<a href="<$mt:EntryPermalink$>?p=' . $prev . '">< Previous Page</a>';
}
if ( count( $parts ) > 1 ) {
     echo ' Page ' . $currentPage . ' of ' . count( $parts ) . ' ';
}
if ( $currentPage < count( $parts ) && count( $parts ) > 1 ) {
     $next = $currentPage + 1;
     echo '<a href="<$mt:EntryPermalink$>?p=' . $next . '">Next Page ></a>';
}
?>

If you don't understand whats going on above, that's ok, just copy and paste that into your template.

That's it, you now have pagination for your long entries. You can see a working example here.

If you're familiar with PHP, you can modify the next/previous links any way you want. Lets say you want to show each page number as a link, here's an example code for that:

echo 'Page: ';
for ( $i=1;$i<=count($parts);$i++ ) {
     if ( $currentPage == $i ) echo $i . ' ';
     else echo '<a href="<$mt:EntryPermalink$>?p=' . $i . '">' . $i . '</a> ';
}

The above code will list each page like:
Page: 1 2 3 4 5

Here's the full code, this can just replace the <$mt:EntryBody$> tag in your template:

<?php
$entrytext = <<<EOF
<$mt:EntryBody$>
EOF;

$parts = explode("<!--more-->", $entrytext);

$currentPage = (isset($_GET['p'])) ? $_GET['p'] : 1;
$currentPart = $currentPage - 1;

echo $parts[$currentPart];

if ( $currentPage > 1 ) {
     $prev = $currentPage - 1;
     echo '<a href="<$mt:EntryPermalink$>?p=' . $prev . '">< Previous Page</a>';
}
if ( count( $parts ) > 1 ) {
     echo ' Page ' . $currentPage . ' of ' . count( $parts ) . ' ';
}
if ( $currentPage < count( $parts ) && count( $parts ) > 1) {
     $next = $currentPage + 1;
     echo '<a href="<$mt:EntryPermalink$>?p=' . $next . '">Next Page ></a>';
}
?>

Disabling Movable Type's dashboard stats

How to fix the broken MT Admin/Internal server error caused by the Dashboard Stats widget.

Movable Type's built in dashboard stats widget is a handy little tool that can display various blog stats such as Entries, Comments, Tags and new Registrations.

If you want to remove or disable this feature, you just click the little X icon in the top right of the widget.

However, while working with large blogs with many comments, visitors and such, the blog's dashboard can time out or display an internal server error because it can not generate the large amount of data for stats. One way to identify the dashboard stats as the problem is only the Blog Admin home page produces an error, while all other admin pages still work, such as Manage Entries, or the blog Preferences.

The simple way to disable dashboard stats, is adding this line to your mt-config.cgi file:

StatsCachePublishing Off

This will disable stats across the MT platform, but if you have multiple blogs, and you want to keep the stats enabled for the other blogs while disabling only for the problem blog, read below.

Of course you can't disable the stats because the page wont even load to click the little X. Also, unfortunately, the data that determines if the stats should be displayed is in a Binary 'Blob' data field in the database, which can't be edited through normal database editor such as phpMyAdmin.

Some users get around this by going directly to another page in MT admin, such as Manage > Entries or any other page other than the Blog's admin home, or 'dashboard'.

So, the work around I found to disable the stats widget is by editing the dashboard stats template in Movable Type. To do this, you need to edit the template "blog_stats.tmpl" which is in your "/mt/tmpl/cms/widget" directory.
Once you open the file, scroll down to the very bottom, and you will see this line:

<mt:var name="blog_stats">

That line is what displays the blog stats on the Dashboard, so you can simply delete that line and save/upload the file.

Now you will be able to view the Blog Admin home page finally! You'll notice it will still display the dashboard widget, but will not show the data. You can then disable the widget by clicking on the X, and re-add that line back into "blog_stats.tmpl".