Wouldn't it be nice to create custom pictures for attachments on the Web. Now it is possible.
e.g. a custom picture of html page you attach to a document instead of the ugly picture Domino create for an attachment. Use the following steps:
1 - create a subform
2 - place all the code in passthrough html except the fields with the @formula's
3 - when you have created the subform you only have to place a editable field with attribute
type="hidden" that has a default value of "0" and is called:
$V2AttachmentOptions (to hide the attachments domino generate)
4 - place the subform on the document where you want the pictures to be visible.
You can easily adjust the code to create more custom pictures of attached document.
By the way: the custom pictures you use must be in the imageresource of the database.
name // where name is an editable field with attribute type="hidden"
<Script> // Declaratie variabelen
var frm = window.document.forms[0];
var countAtt =attNo; // Where attNo is a computed for display number field with the formula
@Attachments
// Array with data per attachment
var Attach=new Array(countAtt);
// Alle names of Attachments separated with a ~
var attName ="AN"; // where AN is a computed for display text field with the formula
@Implode(@AttachmentNames;"~")
// fill the field Name with the values of attName
frm.Name.value=attName;
// Loop through all attachments and the array attName
for (var i=0; i
// Fill Variabele dummy with the value of the Name field
var dum=frm.Name.value;
// fill Variabele str with the position from the first ~ form right
var str=dum.indexOf("~");
// walk through dum and extract the last character of each name and put these in array
Attach
if (str>-1)
{
// most right attachmentname
var a=dum.substr(0,+str);
// Rest of the de variabele dum
var rest=dum.substr(str+1,dum.length);
// fill array Attach with the name of the attachment
Attach[i]=a;
// fill field Name with the rest of the attachment names
frm.Name.value=rest;
}
else
{
// When field Name does not contain ~ anymore, there is only one name left
Attach[i]=frm.Naam.value;
}
Attach[i]=frm.Name.value;
var ID="docID"; // where docID is a computed for display text field with the formula
Text(@DocumentUniqueID)
var pic=Attach[i];
var ext=pic.substr(pic.length-3, pic.length);
// ext contains now the extension of the attachment name (jpg, gif etc)
switch(ext)
{
default:
// create a new custom picture of the attachment.
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../overig1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "jpg":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../graphic1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "bmp":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../graphic1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "gif":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../graphic1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "txt":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../txt1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "tml":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../html1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "xls":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../excel1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "doc":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../word1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + "
");
break;
case "db":
document.writeln("<A HREF=" + ID + "/$File/" + Attach[i] + ">" + "<IMG
SRC=../db1.jpg?OpenImageResource BORDER=0 ALT=" + Attach[i]+ ">" + "</A>" + " ");
break;
case "":
break;
}
}
</Script>
This was first published in March 2001