I wrote this plugin because I was feeling lazy. I did not want to track down the titles for all the pages I have linked to, so I wrote a plugin to do it for me. Introducing MTLinkTitles.
Download one of the following files, unpack it, and place link_titles.pl in your plugins/ directory.
Usage example:
<MTEntryBody link_titles="1">
link_titles
- When this filter is applied, any anchor tag (i.e. <a href="blah blah">) that appears in the resulting text will be visited to gather the title of the page, which will then be added to the tag itself (e.g. title="Page Title").
- The titles will be cached with MT::PluginData so that once a title is found, no further HTTP requests need to be made. If the title has changed and you would like to get the new one, just browse through the mt_plugindata table and delete the row with MTLinkTitles as the plugin value and the URL as the key.
- If that doesn't work well for everybody, I'd be willing to work up another cache-clearing method.
Update (2003-06-08 11:27)
- No, this will not override existing title attributes.
what about links that already have title="" attributes? will it change them as well?
That's very useful, it's just that quite a lot of web sites don't provide a useful <TITLE> tag, so I end up fixing it by hand.
It somehow goes back to the previous comment, if an existing title attribute could override the automatic gathered one - I believe that would be the most useful behaviour.
That's very useful, it's just that quite a lot of web sites don't provide a useful <TITLE> tag, so I end up fixing it by hand.
It somehow goes back to the previous comment, if an existing title attribute could override the automatic gathered one - I believe that would be the most useful behaviour.
I get an error when I try to run the command.
An error occurred:
Can't call method "stash" on an undefined value at /home/jmevius/public_html/the/mt/plugins/link_titles.pl line 23.
Any ideas?
I'm using this plugin and I was wondering is there a way that this plugin can pull the titles from every link on the page besides the ones in MTEntryBody?
I found a nasty bug in this today that broke a lot of links on our site. When a URL uses bookmarks, the site URL is getting put into it. So the original HTML is:
And that gets formatted into the following with this plugin:
The quick fix was to change the code on line 70 to this:
if ($loc !~ /^http:/ && $loc !~ /^\#/) {
Hope this helps.
This times out my blog rebuilds whenever I try to use it--things rebuild verrrrrrry slowly and eventually time out with an error 500. Is there a way around this?
quite nifty, but what would be cool would be if one could have a LinkName plugin that actually sets the displayed hyperlink name as the page's title