|
watje
about trance
This is a little macro that generates a random link every time the page that the macro is on gets published. You can see an example on my weblog homepage. It's the picture under the calender.
You will need a links.xml file somewhere. It resembles the navigator links file. The root tag is "links" and it has an added "picture" property for the items element. Here's a small example:
<links>
<item name="White Label Euphoria" pagename="http://www.amazon.co.uk/exec/obidos/ASIN/B00005YT8G/watje-21" picture="WhiteLabelEuphoria.jpg"/>
<item name="Global Underground 19: John Digweed in Los Angeles" pagename="http://www.amazon.co.uk/exec/obidos/ASIN/B00005852U/watje-21" picture="GU19.jpg"/>
<item name="Northern Exposure III: Expeditions" pagename="http://www.amazon.co.uk/exec/obidos/ASIN/B00000ID2O/watje-21" picture="NE3.jpg"/>
<item name="BBE - Games" pagename="http://www.amazon.co.uk/exec/obidos/ASIN/B0000085CP/watje-21" picture="bbeGames.jpg"/>
</links>
Then you can use the following macro te get a random link from this file. Don't forget to change the directory. You could put this directly on a page, or you can add it to your workspace.
on getRandomLink () {
local (s = "");
local (f = user.radio.prefs.wwwfolder+"links.xml");
local (table);
xml.compile (file.readWholeFile (f), @table);
local (adrlinks=xml.getAddress(@table, "links"));
local (ltable=xml.getAddressList(adrlinks, "item"));
local (i = random(1,sizeof(ltable)));
local (name = xml.getAttributeValue(ltable[i],"name"));
local (url = xml.getAttributeValue(ltable[i],"pagename"));
local (picture = xml.getAttributeValue(ltable[i],"picture"));
s="<a href=\""+url+""><img src="http://radio.weblogs.com/0118796/images/sug/"+picture+""></a>";
return s}
Feel free to ask me any questions or suggestions you might have.
© 2003 Peter Backx
Last Update: 7/03/2003; 18:39:59

|