March 05, 2006
MT hack, recent comments
Looking around the blogosphere, I was rather envious of those sites that displayed recent comments on their Home page. So I did something about it. I bought "Hacking Moveable Type" by Jay Allen, Brad Choate, Ben Hammersley, and Matthew Haughey. Should you decide to buy a copy, I must warn you that it is rather geekie and not for the faint hearted so be prepared to do a lot of head scratching. But the twenty-four hours of torment was worth it when I finally got the Recent Comments in the right side panel just the way I wanted it.
First I "created a new module template" under the module tab in the templates section of MT dashboard. I named it recent_comments.inc - catchy huh?
Then I typed that same name into the field where it says, "Link this template to a file". The text that you type in the screen goes into the database and MT creates a file in the MT directory on your server with the name you type in this field. It took me a while to understand this. It is explained in the book better than the installation instructions that come with MT.
Just as there are lots of ways to skin a cat, there are lots of ways to add recent comments. The authors of this book provided a lot of different examples. I experimented with them all, trying to figure out how they were different. That was the fun part. I settled on the version below.
Then all I had to do was put an include in the Main Index where I wanted the list to show up. The include line looks like this.
Your name for the file might be different. I chose recent_comments.inc
I did find one apparent mistake in the book. On page 20, there are two pieces of code at the bottom of the page. It is rather confusing because the second must be inserted into the first but one tag line is left out. The MTCommentEntry tag goes after the MTComments and of course there needs to be a matching closing tag.
I learned a great deal more than I did know about the inner workings of MT with this book and through trial and error. Maybe next time, I will try writing a plugin.
Posted by roadapples at 08:56 AM | Comments (5)