Full Speed

[ May 17, 2006 ]

New Feature: Related Entries

There’s a new Related Entries feature here at Full Speed today, courtesy of Adam Kalsey. You can see it in action below. It’s a quick, simple hack that uses MySQL’s fulltext queries and Brad Choate’s eternally useful MTSQL plugin. For the sake of documenting the way things work on this site, I will document the basic steps here.

1) Add a fulltext index to the mt_entry table:

2) Add the query to the individual entry archive template in MT:

<MTSQLEntries query="
SELECT entry_id, MATCH (entry_keywords, entry_title, entry_excerpt)
AGAINST ('[MTEntryKeywords encode_php='q'] [MTEntryTitle encode_php='q']')
AS score
FROM mt_entry
WHERE MATCH (entry_keywords, entry_title, entry_excerpt)
AGAINST ('[MTEntryKeywords encode_php='q'] [MTEntryTitle encode_php='q']')
AND entry_id != '[MTEntryID]'
AND entry_blog_id = [MTBlogID]
ORDER BY score DESC
LIMIT 0 , 4"><li><a href="<MTEntryLink>">
<MTEntryTitle></a></li></MTSQLEntries>

Possibly Related:

© 2014 Scott Johnson
• •