Project: BlogSphere (Managed by )
Icons in LatestDownloads block
Jason Engel on 09/23/2006 at 10:00 AM
I like using the LatestDownloads block to distribute torrent files, images, and soundclips to readers of my site. What I did not like about the default appearance of this block in the web page was how each item in the list was preceeded with ** instead of something a little more interesting.
Originally, I had gone into the LatestDownloads field of the D6.SideBlocks subform and changed the part that includes the ** to use one of the many bullets included in the blogsphere template. Eventually, that wasn't flexible enough for me though because after time I wanted to visually display what each kind of file is, and that field didn't seem flexible enough to easily do that. The code I first tried was ugly.
So, after much thinking, my solution was the following:
In the (DOWNLOADS) view, change the third (block links (hidden)) column's formula as follows:
type := @Right(@AttachmentNames;".");
bullet := @If(type="torrent"; "<img src='ipod.png'>";
type="pdf"; "<img src='page_white_acrobat.png'>";
bullet + " " + "<a href='DOWNLOADS/" + @Text(@DocumentUniqueID) + "/$FILE/" + @AttachmentNames + "'>" + StoryTitle + "</a>"
You must also go into the LatestDownloads field in the D6.SideBlocks subform and change it's formula to the following (or whatever edit you need to make to remove the bullet):
dnlist := @DbColumn("" : "ReCache"; ""; "DOWNLOADS"; 3);
dnlist := @If(@IsError(dnlist); "Error retrieving list of downloads"; dnlist);
dnlist := @Subset(dnlist; 8);
@Implode(dnlist; "<br>") + "<br><br>All download details are <a href=\"DOWNLOADS\"><b>here</b></a>"
Now, obviously, my example here only displays four different file types with a fifth being a paperclip for any unknown filetypes. Expand the list and change the icons to suit your needs (note that the mp3.png I use is a personal addition, but all the other graphics are in the default blogsphere template).
I hope that perhaps this tiny alteration might get included in a future version, but if not, maybe someone else will find this tidbit useful on their own.
For an example of this code in use, you can check out my site at http://www.u2unes.com and look in the topmost sideblock on the left ("U2unes Torrent Downloads").
|Entered 23-Sep-2006 10:00 by Jason Engel. Last Modified <none> by <none>.|
Check out other projects