June 29, 2004
Creating Inline TrackBacks
For my next trick, I'd like to show you how to create inline TrackBack postings that show up on your individual entry archive pages instead of in a separate pop-up window. I personally hate pop-up windows no matter what the content, so I steer clear of them on my web site. Having been dismayed to see that the original Comments and TrackBack postings in MT were displayed in pop-up windows, I immediately went to work researching a way to have them display in a normal window rather than a pop-up.
I'm running MT 2.661, so the code shown should be consistent for versions prior to 2.661. I've not worked with MT 3.0D, so my apologies folks, but you're on your own to make the appropriate code modifications, if any, between 2.661 and 3.0D.
Here's a screen shot of the pop-up window we're starting out with.

And here's a screen shot of where we want to end up.
The basic idea is this -- rather than have TrackBack information displayed in the default pop-up window, we instead code the TrackBack information within the Individual Entry Archive page. We then remove the call to the pop-up TrackBack window from the Main Index page and in its place add code that will direct us to the section of the Individual Entry Archive page that contains the TrackBack information. The main steps are:
- Make a backup copy of the Main Archive template.
- Make a backup copy of the Individual Entry Archive template.
- On the Individual Entry Archive template, remove the call to the TrackBack pop-up window.
- On the Individual Entry Archive template, add the TrackBack information code where desired.
- On the Main Index template, remove the call to the TrackBack pop-up window.
- On the Main Index template, add a link to the TrackBack information you just coded to your Individual Entry Archive template.
Without further adieu, let's jump right in and get to work.
Begin by opening the text editor of your choice. Open a new, blank document.
Log in to your MT interface. Choose Manage Weblog. At the Manage Weblog screen, choose Templates from the menu on the left side of the screen. MT generates a list of templates being used (or that can be used) by your blog.
From the list of index templates, choose Main Index Archive. The resultant screen shows information about the template in addition to the template's code. Copy and paste the entire body of code into your blank text document. Save the file as mainindex_v0(mmddyy).htm where mmddyy represents today's date in two-digit month-day-year format. This file is our backup copy of the Main Index Archive template.
Repeat this process with the Individual Entry Archive template. Save the file as indiventry_v0(mmddyy).htm. This file is our backup copy of the Individual Entry Archive template.
Because we don't want to overwrite our backup copies, copy the contents of mainindex_v0(mmddyy).htm to a new file and save it as mainindex_v1(mmddyy).htm. Repeat with indiventry_v0(mmddyy).htm. All code modifications will be made to the “version 1 (v1)” copies.
Let's now add the TrackBack information to the Individual Entry Archive. Open indiventry_v1(mmddyy).htm. Look for the following code:
| <a href="<$MTCGIPath$><$MTTrackbackScript$>?__mode=view&entry_id=<$MTEntryID$>" onclick="OpenTrackback(this.href); return false" title="Add a TrackBack to this Post">TrackBack</a>
</MTEntryIfAllowPings>
This code calls the pop-up window script for displaying TrackBack information. Delete this entire block of code and in its place add the following:
| <a href="<$MTEntryPermalink$>#trackback" title="Add a TrackBack to this Post">TrackBack (<$MTEntryTrackbackCount$>)</a>
</MTEntryIfAllowPings>
This code links you to the TrackBack section of the Individual Entry Archive page. As it stands now, our Individual Entry Archive page does not have a TrackBack section. We need to add it. This next block of code contains the TrackBack information.
<div class="comments-body">
<p>TrackBack URL for this entry: <$MTEntryTrackbackLink$></p>
<MTEntryIfAllowPings>
<MTPings lastn="15">
<p><a name="<$MTPingID$>"></a><$MTPingBlogName$> linked with <a href="<$MTPingURL$>"><$MTPingTitle$></a><br /><$MTPingExcerpt$><br />Tracked on <$MTPingDate$></p>
</MTPings>
</MTEntryIfAllowPings>
</div>
This completes the modifications to the Individual Entry Archive template. Next, we need to modify the Main Index template, so open mainindex_v1(mmddyy).htm. We will remove the call to the TrackBack pop-up window and replace it with a hyperlink to the TrackBack section of the Individual Entry Archive. Locate the following code:
| <a href="<$MTCGIPath$><$MTTrackbackScript$>?__mode=view&entry_id=<$MTEntryID$>" onclick="OpenTrackback(this.href); return false" title="Add a TrackBack to this post">TrackBack (<$MTEntryTrackbackCount$>)</a>
</MTEntryIfAllowPings>
Replace it with ...
| <a href="<$MTEntryPermalink$>#trackback" title="Add a TrackBack to this Post">TrackBack (<$MTEntryTrackbackCount$>)</a>
</MTEntryIfAllowPings>
Be sure to save each template after making changes. You will also need to rebuild them before the changes will be reflected on your site.
This tutorial is the result of techniques I learned from Kevin at “Wiz Bang Blog” and Elise at “Learning Movable Type”. To educate yourself further about inline TrackBacks, be sure to read their tutorials, too.
Posted by Kasey on June 29, 2004 09:46 AM | Filed Under: Movable TypeYou never cease to amaze me! If I had your smarts, there's no telling what I'd be doing now! I have only touched on MT a bit and won't get back to it until the cold of winter keeps me confined indoors, but I'll definitely be following your lead and your very thorough tutorials when the time comes! Again, I am impressed with your ability to learn these things and then teach others. You are sumpin'! :)
Posted by: Bunni on June 30, 2004 07:05 AM
