Content Management
Autolink URLs in MT Entries
Freshness Warning
This blog post is over 20 years old. It's possible that the information you read below isn't current and the links no longer work.
16 Aug 2004
One of the things I really hate about reading newspaper Web sites is they often include URLs but don’t link them. So you have to copy and paste to open them (or just rightclick with the right Firefox extension).
I don’t want my site to look like a big, dumb newspaper. So I wrote a filter using Brad’s regex plugin to autolink URLs in entries. It hasn’t been extensively tested but it has worked for a the half-dozen or so entries in the Project X blog.
Install the regex plugin and then add this to the top of your templates…
<MTAddRegex name="autolink">s![> ](http://[^<" ]+)!<a href="$1">$1</a> !g</MTAddRegex>
Then add the attribute regex="autolink"
to your MTEntryBody and MTEntry more tags in your templates: <MTEntryBody regex="autolink">
.