OpenNTF.org - Displaying associated file att
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Displaying associated file attachment images using computed text on a html form 
Rating:
Rating: 4.5 , Number of votes: 2 
Contributor:
Jon Hart 
Category:
HTML, Lotus Formula, Other 
Type:
Example Code 
Notes Version:
R6.x, R5.x, R7.x 
Last Modified:
18 May 2006 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
This is a little piece of code I came up with while developing a possible future OpenNTF project...More to come on the project as it proceeds...


1. Create a Notes form with rich text field or file attach control
2. Create a Html web version of the form
3. Add some attachment of different file types
4. Add the provided images as image resources in the same db, (or place in central db & modify code "HINT" look @ line-->e:"\" src=\"/"+@WebDbName+"/i_SM_";
)
5. Create a <Computed Text> where you want on the form & add the following code:

Usage / Example
REM "The following code will generate a list of attachments & display the associated file image";
REM "You can add more images for other file types, I just did some basic ones.";
a:=@Text(@DocumentUniqueID);
b:=@AttachmentNames;
b2:=@Implode(b;"~")+"~";
c:=@Attachments;

d:="<img id=\"img_Attach";
e:="\" src=\"/"+@WebDbName+"/i_SM_";
f:=".gif\" class=\"img_Attach\" style=\"border:0;\" alt=\"";
g:="\">";

bat:="MS-DOS Batch File";
bmp:="Bit-Map Image File";
exe:="Application";
gif:="Graphics Interchange Format Photo";
jpg:="Joint Photographic Experts Group Format Photo";
ms:="Microsoft";
msxls:=" Excel Spreadsheet";
msppt:=" PowerPoint Presentation";
msdoc:=" Word";
pdf:="Adobe Acrobat - 'Portable Document Format' File";
txt:="Text Document";
xml:="XML - 'eXtensible Markup Language' File";
unk:="Unknown File Format";
zip:="WinZip Archive";

types:=
"||BAT~"+bat+
"||BMP~"+bmp+
"||DOC~"+ms+msdoc+
"||EXE~"+exe+
"||GIF~"+gif+
"||JPG~"+jpg+
"||PDF~"+pdf+
"||PPT~"+ms+msppt+
"||TXT~"+txt+
"||XLS~"+ms+msxls+
"||XML~"+xml+
"||ZIP~"+zip+
"||";

tmp:="";
tfn:="";
tfex:="";
talt:="";
tgif:="";
ilnk:="";

@For(x:=1;x<=c;x:=x+1;
tfn:=@Word(b2;"~";x);
tfex:=@UpperCase(@Right(tfn;3));
talt:=@Trim(@Word(@Right(types;tfex+"~");"||";1));
talt:=@If(talt="";unk;talt);
tgif:=@If(talt=unk;"UNK";tfex);
ilnk:=d+@Text(x)+e+tgif+f+talt+g;
tmp:=tmp+"<br><a href=\"/"+@WebDbName+"/0/"+a+"/$FILE/"+tfn+"\">"+ilnk+"&nbsp;"+@URLEncode("ISO-8859-1";tfn)+"</a>"
);
@If(c=0;"";"<br>"+tmp);
Code Attachments
i_SM_images.zip (9 Kbytes)
example.gif (5 Kbytes)
 Comments
Posted by Ed Maloney on 05/22/2006 04:32:55 PMGreat Stuff - Thanks!
I've been looking for something like this to give my Domino apps a less "Notesy" look.
Works great.
Thanks
 Add your comment!