MovableBlog: Archives: April 2002

A weblog about the Movable Type Publishing Platform and other geekery

April 30th, 2002

MT 2.01 »

Apparently I'm way behind on the news that MT 2.01 is coming out soon. That's what I get for paying too much attention to the Tips & Tricks forum and not enough attention to the MT main site.

I'm most looking forward to the "Ability to limit which index templates are automatically rebuilt" (so that I can rebuild the random entry template, which is huge, separately). Partial support for meta Weblog API also looks promising. This would presumably allow posting via AIM or any other app instead of using MT's interface (something like how LiveJournal has a small, constantly-running Windows app to post easily and quickly).

Since Ben said he'd release 2.01 in a week or two after he announced it (which was on the 19th), it should be available any day now.

Posted by Richard at 03:31 AM | Category: MT | Comments (1)

April 28th, 2002

Multiple Categories Tip »

Using MT, some Javascript and PHP, and a lot of duct tape, I've created a multiple category listing that floats over a blog and closes itself when the category is clicked. There's also a "Close Window" option, if curiosity-seekers just want to see which category a post belongs to.

Things necessary for this to work: Movable Type 2.0 (does not work with previous versions!); PHP on your server; Javascript enabled on the client's browser, and a little patience to work the bugs out. It's...well, it's a little complicated.

Setup:

First: create a directory on your server (preferably in your archives directory) for the multiple category listing.

Second: if you don't have Individual archives already enabled, enable them, and go on to the next step. If you already have Individual templates enabled, create a new one called mine "Multiple Category Listing".

This is done in Blog Config, Archiving, and the "Add New..." button. While still in the archives option, make sure (if this is a second Individual Archive template), to have the original template (e.g. not "Multiple Category Listing) as your default template. This is done by selecting it with the radio button. Make sure that the "Individual" check box is selected under "Archive Type".

Third: the way I have it is all the files themselves exist in one separate directory. Necessarily, this takes up disk space, because whether or not they are assigned multiple categories, all individual entries will get the second individual file. Once having created the "multiple" directory (choose your own name if you like), I set the Archive File Template to be "multiple/<$MTEntryID$>.php" (without quotes). Use whatever extension you like instead of .php, as long as PHP works on extensions other than the .php extension (which my server does not).

Code:

In your main blog template, the code inside that goes inside the <MTEntries> tags looks like:

[<? $count = 0; $i = 1; ?>
<MTEntryCategories><? $count++; ?></MTEntryCategories><?php

if ($count > 1)
?><a href="" onMouseOver="(window.status='Show Categories');
return true;" onMouseout="window.status=' '" onClick="newwindow 'URL_for_Multiple_Entry_Directory/<$MTEntryID$>.php');return false">Multiple Categories</a><?php
}

else
{
?>Category: <a href="<$MTEntryLink archive_type="Category"$>"><$MTEntryCategory$></a><?php
}
?>]

Important: URL_for_Multiple_Entry_Directory must be replaced by the absolute URL of the directory containing the individual multiple category listings.

Tweak as necessary.

Now for the Javascript. This code goes in the header of your main blog's Index Template:

<script language="javascript" type="text/javascript">
function newwindow(theURLtwo)
{
window.open(theURLtwo,'jav','width=300,height=200,resizable=yes');
}
</script>

Now, for the "Multiple Category Listing" template, my code looks something like this:

<html>
<head>
<script type="text/javascript">
function MM_openBrWindow(theURL) {
if (window.opener != null){
window.opener.location=theURL;
window.close();
}
}
</script>
</head>

<body>
<table cellpadding="7">
<tr>
<td class="MTTitle">Categories for &quot;<$MTEntryTitle$>&quot;</td>
</tr>
<tr>
<?php

$text = "";
<MTEntryCategories>
$text = $text."<a href=\"javascript:MM_openBrWindow('<$MTCategoryArchiveLink$>')\"><$MTCategoryLabel$></a><br/>";
</MTEntryCategories>
print $text;

?></td>
</tr>
<tr>
<td>[<a href="javascript:window.close();">Close Window</a>]</td>
</tr>
</table>
</body>
</html>

Again, tweak as necessary (adding a CSS would be a good start!).

Not the most elegant way, and people might have problems related to CHMODing the directory. I make no guarantees that this will work, but spent enough time on it to somehow make it work on my site. And make sure you read the comments: likely I've forgotten to add something, or there's a correction or two to be made.

Posted by Richard at 02:12 AM | Category: | Comments (0)

April 25th, 2002

Lack of posts »

Sorry for the lack of posts lately. Soon I'll come up with a detailed post on how I implement multiple categories on my site. The "Next Couple of Days" post on my main site is a good example of that. It uses a combination of an extra individual template, MT tags, PHP and Javascript to achieve the effect. It's done almost entirely on 'borrowed' code (from the Tips and Tricks forum, from Javascript help sites, etc.), but the way it's combined is, I believe, original.

The detailed post should come on Sunday, with a link to it posted to the Tips and Tricks forum.

Posted by Richard at 06:39 PM | Category: MT | Comments (0)

April 24th, 2002

HHGG Text Game »

DNA/HHGG Infocom Adventure text-based game

This game brings me back to the days when I had a Sanyo 555 (a picture sans monitor: the monitor we had had bright green text on a green background). I remember not doing very well back then (getting only to the point where I got the babel fish from the Vogon ship), and since I'm going on memory trying to get back to that point, now I can't remember how to get past the bulldozer. Yeah, I know. Oh well, I remember how the story goes, having read all 5 of the "trilogy", but translating that into text-based-computer-game action is another thing. Oh well, should get repeated visits by yours truly, if only for the nostalgia.

(I'm pretty sure I found this first at MetaFilter, which is still a really great site for links I'd never even dream of looking for.)

Posted by Richard at 02:56 PM | Category: Geekery | Comments (2)

April 22nd, 2002

Restricted Post »

How to make restricted access posts on your site: requires PHP, and a dash of patience. I have both, so this is something I might implement on my main site and/or on a photoblog site a friend wants me to create.

Bravo!

Posted by Richard at 03:22 PM | Category: MT | Comments (0)

April 20th, 2002

Learned Something New »

Well, there you go! I learned something new today! Of course, it was in the manual, but sometimes it takes someone to point it out (i.e. including multiple categories in a blog post but excluding one). Also a good idea for including 'multiple blogs' is using one blog and use categories instead (hezair's message in this thread). I'm sticking with multiple blogs with PHP includes (i.e. RichFilter).

But combine the two (excluding a category from a listing, and using a category listing somewhere else) is a good way to have 'multiple blogs' on one page!

Posted by Richard at 07:14 PM | Category: MT | Comments (0)

April 16th, 2002

"On This Day" »

Well, isn't that clever! It's probably not specific to MT (does GreyMatter allow daily templates?) but Brad Choate offers some PHP code for linking to posts "on this day" in past years on your blog.

If I had daily templates set up on my site, I'd definitely use this!

Posted by Richard at 01:31 PM | Category: MT | Comments (0)

April 13th, 2002

Less than N Days »

As an addendum to the monthly tags post, there's another component of the Recently quasi-blog that was a little tricky at first. I wanted a way to show that another blog had been updated within n days. The way I did this was with some MT and PHP magic.

I created an index template that looks something like this (the filename in my case is dateoflastentry.php):

(the code for the timestamp was derived from this example)

<?php function makeTimeStamp($year,$month,$day) { return mktime(0,0,0,$month,$day,$year); } <MTEntries lastn="1"> $startDate = makeTimeStamp (<$MTEntryDate format="%Y"$>, <$MTEntryDate format="%m"$>, <$MTEntryDate format="%d"$></MTEntries>); ?>

The code that I have looks like this:

<?php

function lessThanNDays($timestamp)
{
$now = time();
$betweenTodayAndLastN = $now - $timestamp;
$nDays = 3;

$nDaysAgo = 60 * 60 * 24 * $nDays;

if ($betweenTodayAndLastN < $nDaysAgo)
{
return TRUE;
}
else
{
return FALSE;
}
}

include("recemment/dateoflastentry.php");
if(lessThanNDays($startDate))
{
print("<b>Recently</b>");
}
else
{
print("Recently");
}
?>

The include statement is in bold. Note that it appears in a different directory than the main blog, but just because that's where the Recently blog appears.

The $nDays variable in the lessThanNDays function is set to 3, so that any blog entry with a timestamp of less than 3 days ago results in "Recently" appearing in bold. Not the most elegant way to do it. But it does work!

See also this post in Tips & Tricks.

Posted by Richard at 06:05 PM | Category: MT | Comments (0)

April 12th, 2002

Smilies »

Adding Automatic Smilies hack.

Neat!

Posted by Richard at 10:55 PM | Category: MT | Comments (0)

Google API Hack »

Use the recently introduced Google API in Movable Type.

See also Tips & Tricks post introducing it; info on Google API.

Posted by Richard at 07:08 PM | Category: MT | Comments (0)

Movable Type Blog »

Since there's a blog dedicated entirely to Google, and one dedicated entirely to Mozilla, why not dedicate an entire blog to MovableType?

It's more a way for me to aggregate resources dealing with MT, since it seems to be a growing phenomenon, what with the release of the excellent version 2.0. I welcome any suggestions for this site and am looking for authors to lessen the load of posting.

Update exactly a year later: Yeah, scratch that. The email links don't even work anyway.

Anyway, we'll see how long this great idea of mine lasts. In the meantime, enjoy!

Posted by Richard at 07:00 PM | Category: MT | Comments (1)