WSN Knowledge Base
Featuresspacer Showcasespacer Reviewsspacer Demosspacer Purchasespacer Manualspacer Support
Custom File Attachment Fields
Custom File Attachment Fields
By Paul

By using custom file fields, you can have you visitors upload several files at once for a single object. For articles and comments this isn't so important since you can already let people upload any number of files, but you can also add file uploads to categories and members using custom file fields.

In order to get started on creating a custom file field, visit customizations -> 'add fields' in your admin panel. Any field which you give a name that includes 'attach' in it will automatically become a custom file field, but if you do not wish to worry about this just select 'file' from the type options and it will automatically append 'attach' to the name you give it. Once you click 'add field' you will be told what template changes you need to make to your submission and editing tempalates, or if templates are chmoded the changes will be made for you.

Now that you have the custom file field working, you'll want to make use of it in the display (most likely in the 'show articles in category' and/or 'main index' templates for a category, or the profile for a member). Here's a reference of the template variables you will have available for such display... replace 'CUSTOMATTACH' in each example with the uppercase version of the name of your custom file attachment field.

{CATCUSTOMATTACHTITLE} - The name of the file for display purposes (the same name it had on the computer of the person who uploaded it).
{CATCUSTOMATTACHNAME} - The actual name on disk of the file in the attachments directory.
{CATCUSTOMATTACHDOWNLOADS} - The number of times the file has been downloaded so far.
{CATCUSTOMATTACHFILESIZE} - The size, in bytes, of the file.
{CATCUSTOMATTACHKB} - The size, in kilobytes, of the file.
{CATCUSTOMATTACHWIDTH} - For images, the width of the image in pixels.
{CATCUSTOMATTACHHEIGHT} - For images, the height of the image in pixels.
{CATCUSTOMATTACHDOWNLOADURL} - A download link.

To allow your visitors to download the file:

For a category field, link to download.php?catid={CATID}&field=customattach
For a member field, link to download.php?memid={MEMBERID}&field=customattach
For a link field, link to
download.php?id={LINKID}&field=customattach
For a comment field, link to
download.php?comid={COMMENTID}&field=customattach

Repla ce customattach with the name of your field in all cases, of course. To display them directly as images use the html <img> tag as usual: <img src="download.php?catid=44&field=customattach">


You can resize image attachments by tacking on &width=800&height=600 (this would resize to 800x600).


To show a thumbnail of the file:

For a category field, <img src="thumbnail.php?catid={CATID}&field=customattach&thumbwidth=50&thumbheight=50">
For a member field, <img src="thumbnail.php?memid={MEMBERID}&field=customattach&thumbwidth=50&thumbheight=50">
For a link field, <img src="thumbnail.php?id={LINKID}&field=customattach&thumbwidth=50&thumbheight=50">
For a comment field, <img src="thumbnail.php?comid={COMMENTID}&field=customattach&thumbwidth=50&thumbheight=50">


To delete a custom attachment field file, put this somewhere in the 'edit' form, replacing 'customattach' with the field name:
<input type="checkbox" name="customattachdelete" value="1">

Rating:


5/5 based on 3 votes. The median rating is 5.

Submitted: 03/21/04 (Edited 10/13/08)

Description: Creating, configuring and using custom attachments.

Views: 1812 views. Averaging 1 per day.
In the most recent 30 day period, there've been 8 views.

Previous Article | Next Article


Home    |    Features    |    Showcase    |    Reviews    |    Demos    |    Purchase    |    Manual    |    Support