Getting all Entries Linked to an Asset in Movable Type

| No Comments | No TrackBacks |
A while ago I needed to be able to display a list of images along with the blog entries in which they occurred.  Movable Type has an <mt:EntryAssets> tag that makes it very easy to show a list of entries with the images in them, but the reverse tag (<mt:AssetEntries>) didn't exist, unfortunately.
My solution

Back then, I solved this with a very convoluted workaround: first, dump all entries (or at least the 1000 most recent ones) using an <mt:entries> tag, then use the <mt:entryassets> tag to get the images in question.  All this was then put into a large hash with the asset id as key, after which I looped over this hash by key and displayed the relevant entry information.

This works fine, as long as the number of entries is not too large, and eventually it becomes slow.

You'll also notice I don't provide a code example.  Here is why:

The better solution

Byrne Reese of Endevver recently released a plugin named 'ExtraTags'. One of the extra tags this plugin adds to your Movable Type installation is... <mt:AssetEntries>.   Thanks to Byrne, no more slow-publishing kludgy workaround templates are needed anymore to get the entries related to an asset.  Which is nice.

No TrackBacks

TrackBack URL: http://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/76

Leave a comment