I use the following code in order to display only the attachment files my users attach on their websites (by excluding multimedia files to be displayed, .jpg, .gif, .wmv etc).
attNames := @LowerCase(@AttachmentNames);
allowedExt := “.doc”:“.pdf”:“.xls”:“.ppt”:“.rar”:“.zip”:“docx”: “xlsx”:“pptx”:“ACCDB”;
aref := “”;
aref1 := “<a href="” + @Text(@DocumentUniqueID) + “/$file/”;
aref2 := “" target="_blank" class="simplelink"><img border=0 hspace="4" src=…/”;
aref3 :=
“word.gif Alt="Click here: Open the Word file" title="Click here: Open the Word file">”:
“pdf.gif Alt="Click here: Open the PDF file" title="Click here: Open the PDF file">”:
“excel.gif Alt="Click here: Open the Excel file" title="Click here: Open the Excel file">”:
“ppt.gif Alt="Click here: Open the Powerpoint presentation" title="Click here: Open the Powerpoint presentation">”:
“rar.gif Alt="Click here: Download the RAR file" title="Click here: Download the RAR file">”:
“winzip.gif Alt="Click here: Download the ZIP file" title="Click here: Download the ZIP file">”:
“docx.gif Alt="Click here: Open the Word file" title="Click here: Open the Word file">”:
“xlsx.gif Alt="Click here: Open the Excel file" title="Click here: Open the Excel file">”:
“pptx.gif Alt="Click here: Open the Powerpoint presentation" title="Click here: Open the Powerpoint presentation">”:
“ACCDB.gif Alt="Click here: Download the Access file" title="Click here: Download the Access file">”;
@For(m := 1; m <= @Elements(allowedExt); m := m + 1;
ext := allowedExt[m];
@For(n := 1; n <= @Elements(attNames); n := n + 1;
newAref := @If(@Contains(attNames[n]; ext); aref1 + attNames[n] + aref2 + @Replace(ext; allowedExt; aref3) + attNames[n] + “
”; “”);
@If(newAref != “”; aref := aref : newAref; “”)));
aref := @Trim(aref);
@For(m := 1; m <= @Elements(aref); m := m + 1; aref[m]);
@Implode(aref;" ")
However, when I attach docx, pptx, xlsx and ACCDB files they appear on the page two times, once with the “doc” and once with the “docx” image in front of the attachment name.
I would appreciate it if someone could fix this issue as I don’t know what I am doing wrong. Also, is it possible to modify the code and instead of the attachment name the custom title (given by the user) to be displayed as well as the file size of each attached file ( (File Size: " + @Text(@Round(@AttachmentLengths/1004;0,01)) ).
Thanking you in advance.
Nana