Archive for the ‘MT hacks’ Category

Extra field in comments

Friday, March 14th, 2003

As requested by Chris, here’s a hack that will give you an extra field for your comments, and have the contents of that field included in your email notification.

(note: what this will NOT do is show those contents back on your site. I can think of a way to do that with php and mySQL (with a slight detour on the comment form submission - similar to the way comment subscribe works) and I can write up a second tutorial on that one if there’s interest. OR 10 points to the person that can figure out how to hack that directly into MT.)

(another note: if/when you do upgrades to MT - you will need to do this hack again (or one similar depending on how much changes in the version of MT you’re working with). This tutorial assumes you’re using MT 2.63 - although it also applies to 2.62)
(more…)

Archive Redirects made (more) simple

Tuesday, February 25th, 2003

A few weeks ago, Kristine posted about Redirects in MT, and this got me thinking. I had already looked at an archive mapping solution which was recently updated, but it required that I have access to the server config files (not just a .htaccess file) because a RewriteMap can only be defined in the server config files.

So tonight when I decided, after a great deal of pondering (about 10 minutes), to change my archiving format to something that didn’t produce 1000+ numerically named directories I needed a way to map the archive numbers to their new named location. Here is the solution I came up with, based on some modifications of the pre-existing code.

First download mt-archivefinder.cgi and rename it to mt-archivefinder.cgi (or any other name that suits your purposes). Put it in the MT directory.

You will need to change a couple of the lines at the top of the file to match your server’s configuration. Make sure to chmod the file 755.

Next you will need to do some mod_rewrite mojo with a .htaccess file. Create a .htaccess file or edit the existing file in the root of your archives directory. To that file add:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/archive/[0-9]{6}.html
RewriteRule ^(.*).html$ /mt/mt-archivefinder.cgi?$1

You will need to change it to reflect your path structure. If all goes well, you will be automagically redirected from any numbered file like /archives/000001.html to whatever new archiving scheme you enter into the individual archive template in the Weblog Config panel in MT.

For example, I was using

<$MTEntryID pad=”1″>/index.php

and now I’m using

<$MTArchiveDate format=”%Y”$>/<$MTArchiveDate format=”%m”$>/<$MTEntryTitle dirify=”1″$>/index.php

I used the following mod_rewrite rule to automatically forward all links to the old archive style to the new archive style.

RewriteCond %{REQUEST_URI} ^/history/[0-9]{6}/
RewriteRule ^(.*)/$ /mt/mt-archivefinder.cgi?$1

That’s all it takes!

Many thanks to Alex for the inspiration and the code.

Redirects in MT

Wednesday, February 12th, 2003

Earlier today, I saw a lazy web post about using mod_rewrite to redirect pages if you change your MT URLs. Check out Generating MT Entry Redirects.

Another thought that I had today — if you are moving a blog from one location to another (think changing domains), you could use a redirect right in the Individual Archives on the old server through MT before deleting the old blog.
Example: (in the head of an Individual Archive template)

<meta http-equiv=”Refresh” content=”1;url=http://your-new-site.com/archives/<$MTEntryID pad="1"$>.html”>

As long as you are using the same naming scheme with the MTEntryID (which is the default), your old entries will point directly to the new site.

After a while, once people have stopped linking to the old domain, then you could just delete the individual archive files from the old server.

A Variety of MT Things

Sunday, February 9th, 2003

From my travels for today:

:: Want to convert from LiveJournal to MT? Meredith has information on how to do it here and is working on a full tutorial.

:: SimpleComments from Kalsey Consulting Group will allow you to display your comments and your trackback pings all together in one spot. The logic being that trackbacks are really just comments left on someone else’s site. (found at RevJim)

Plugin Directory

Wednesday, December 4th, 2002

There’s been so many great plugins developed for Movable Type since that functionality was added. To keep track of them all, and to help me in answering questions on the forums, I put together a Plugin Directory (powered by MT, of course!) It actually uses some of the plugins that I hadn’t tried out yet (Columnize and Key Values are most notable).

So if you’ve been looking for a solution but don’t have PHP, some of these perl-based plugins may help you out.

Wording based on time

Wednesday, November 27th, 2002

Would you like to have a different saying below your post based on what time it was posted instead of (or in addition to) the date? A poster on the MT forums did, so I cooked up this little script yesterday.

<?
//set the beginning time for each time section - keep the quotes in there
$earlymorn = strtotime(”4:30am”);
$midmorn = strtotime(”9:00am”);
$lunch = strtotime(”11:30am”);
$afternoon = strtotime(”1:00pm”);
$evening = strtotime(”5:00pm”);
$bedtime = strtotime(”9:00pm”);

//This date format is for MT2.5 and above
$t = strtotime(”<$MTEntryDate format=”%X”$>”);

//Modify the messages as necessary - note that the middle of the night one should be in there twice.
if ($t <= $earlymorn) { echo “Past Your Bedtime”; }
elseif ($t <= $midmorn) { echo “Early Morning”; }
elseif ($t <= $lunch) { echo “Mid-Morning”; }
elseif ($t <= $afternoon) { echo “Lunch time”; }
elseif ($t <= $evening) { echo “Afternoon”; }
elseif ($t <= $bedtime) { echo “Evening”; }
else echo “Past your bedtime”;
?>

Enjoy! :)

Add “Listening To” & other fields to your entries

Wednesday, November 20th, 2002

This is a hack that reminds me a lot of “LiveJournal” blogs, and I know many MT users long for it.

So, Scott has made the hack. This one is not for the faint of heart, but it looks very snazzy when you are finished.

Read Scott’s Tutorial here.
BTW, you must be using the mySQL database flava of MoveableType to use this tweak.

6 months of archives

Tuesday, November 19th, 2002

Heather asked me if it were possible to make your archives listing only show the last 6 months one way, and then the rest another way.

She wanted the last 6 months of archives to display like:

November 2002
02 Nov 19: post title
02 Nov 02: post title

October 2002
02 Oct 30: post title…

and then the rest of the archives just in month format like this:

April 2002
March 2002

At first I would have said to do something with <MTArchiveList archive_type-”monthly” offset=”6″> but it that “offset” attribute doesn’t seem to get applied like that (it only offsets specific ENTRIES, not archive types). So I made a very (kind of scary) script to do exactly what she wanted. There may be some shortcuts I’ve overlooked, so please let me know if you think there’s an easier way.
(more…)

More on the MT Comment Spamming

Thursday, October 31st, 2002

I wanted to be sure to note two sites here that also have good information on the MT Comment Spammers:
:: Burningbird’s Comment Spam Quick-Fix
:: Dive into Mark’s Club vs Lojack Solutions

next/previous category archive

Tuesday, October 29th, 2002

Thanks to Lynda and Jenn there is a way to navigate between next and previous entries only within a category. But there has been many requests on the forums for a way to go between the category archives with next and previous like the date-based archives have.

This script will show the linked title of the previous and next categories, alphabetically, on each category archive page.
(more…)