
I just killed most of a perfectly good Sunday afternoon trying to solve this stupid problem in Movable Type, and now that I've got it I had better preserve it for posterity.
All I wanted to do on my home page was display one entry excerpt from my 'Photo' category, selected by most recent date modified as opposed to most recent date authored; this is because I have a big backlog of old photos that I would like to appear on the home page as I add them, regardless of their original date (which I plan to preserve as the entry date.)
The problem is that the only attribute of the <MTEntries> tag that lets you limit the number of entries displayed is lastn, and lastn is only good for displaying entries based on entry_created_on in descending order.
I haven't had many gripes about MT so far, but that's a fairly major one now that I've come across that particular limitation.
The workaround is to use Brad Choate's, SQL Plugin, with this query:
SELECT entry_id FROM mt_entry LEFT JOIN mt_placement ON placement_entry_id = entry_id WHERE entry_blog_id = x AND entry_status = 2 AND placement_category_id = y ORDER BY entry_modified_on DESC LIMIT z
Where x, y, and z are the desired blog id, category id, and number of entries respectively. An entry status of '2' restricts the query to show only entries set to 'Publish'.
I installed the plugin and worked out the above query, only to get an error from the DBI library. As usual, Google was my friend, and pointed me to Mike James' post, Solution to MT SQL plugin DBI error.
The problem is with an older version of the Perl DBI module. The solution: Assuming you have a shell account but not root access to your web server, download the latest DBI module from CPAN, build and install it in your home directory, and tweak MT to use your version instead of the system version. This last is accomplished by adding the line
use lib qw(/home/your_user_name/lib/i386-linux);
above the use DBI; statement in /path/to/mt/lib/MT/ObjectDriver/DBI.pm. See the actual post for more specifics.
I do love Movable Type, but the lack of a more generic, SQL-like 'limit' attribute in the <MTEntries> tag is kind of puzzling.
2 comments
Sort by most recent Sort by
Sort by most recent
Sort by recent using MTSQL
yeah, ok So today I decided
yeah, ok
So today I decided I'd like to have a list of the books I've read recently (besides the ones I'm reading RIGHT NOW) in my sidebar. It's there now, but only because I (and several other people) are awesome. Here's...