iamcal.com

[home] [PDF Version]

Blog Hacks : Using Blogdex with Metalinker

Originally published 1st July 2003

Metalinker

You might be writing about the latest Apple gadget or you might be writing about tensions in the Middle East - and if it's topical you're probably not going to be the only one. But how do you (and how can you help your readers) find out about the other discussions going on around the net?

Metalinker takes a very simple approach - every time you put a link into your website, metalinker uses javascript to add a link to the page on blogdex that lists other people talking who have mentioned that link. And so with just a couple of mouse-clicks people reading your site can read a webful of opinion and debate...

To start, you'll need to grab the metalinker.js from http://www.iamcal.com/files/metalinker.zip. After that, insert the following code, right at the end of your template, before the closing </body> tag.

	<script language="javascript" type="text/javascript" src="metalinker.js"></script>
	<script language="javascript" type="text/javascript">
	<!--

	tag_links();

	//-->
	</script>

The syntax of the tag_links() call varies, depending on what you want it to do: In it's simplist form, just call it with no arguments:

	tag_links();

This tells the scanner to parse every link on the page.

To only link a certain area of the page (such as a weblog), enclose it in a <div> tag and give it an id="" attribute. Then pass the id as the first argument to the scanner:

	tag_links('my_div');

This tells the scanner to transform only links found within the <div> with the id of my_div.

To further exclude links, such as permalinks, then you can filter them out based on url or class. If all your permalinks start with http://www.domain.org/archives/ then call as follows:

	tag_links('my_div','http://www.domain.org/archives/');

This tells the scanner to look in the div for all links that don't start with http://www.domain.org/archives/. If all your permalinks have class="permaclass" attributes then call as follows:

	tag_links('my_div','http://www.domain.org/archives/','permaclass');

This tells the scanner to look in the div for all links that don't start with http://www.domain.org/archives/ and have a class of permaclass. All arguments are optional and you can skip any you don't want to specify by just supplying null:

	tag_links(null,null,'permaclass');

You can also specify the way the link is presented. By default, a 'b' in square brackets is shown. You can supply the three pieces of text (before the link, the link itself and after the link) as arguments to the function. The default (leaving them blank) is equivilent to as follows:

	tag_links(null,'null,null,' [','b',']');

But you can customise it however you want:

	tag_links(null,null,null,'-','more...','');

The seventh argument allows you to set the class of the generated links. By deafult they are given the class autolink but you can specify your class as follows:

	tag_links(null,null,null,null,null,null,'my_autolink_class');

The eighth argument allows you to specify the title of the link (shown as a tooltip, and used by screen readers). By deafult they are given the title "metalink" but you can specify your own as follows:

	tag_links(null,null,null,null,null,null,null,'my title');

If you don't want metalinker to operate on your archive pages, then this can be achived by relative urls. Make sure your archives are in a different folder to your main weblog (e.g. 'archives'). In this folder, create another file called metalinker.js and copy the following code into it:

	function tag_links(){
		return;
	}