FileDownload

From MODx Wiki

Jump to: navigation, search

 MODx Snippet 

FileDownload v2.5
Author 
kylej (website)
MODx Versions 
>= 0.9.5
Last Updated 
1/3/2007

Contents

FileDownload is a snippet that will display a list of files from a user specified directory. This snippet is NOT FileDownloadPlugin but the two can be used together.

Installation

  1. Download the snippet from the Resources Section below.
  2. Copy the filedownload folder contained in the zip file to your /assets/snippets/ directory
  3. Open up FileDownloadSnippet2.5.php in a plain text editor and copy the contents to a new snippet called FileDownload in your manager
  4. Call the snippet in a document, template, or chunk using: [!FileDownload? &getFolder=`assets/files`!]

For a more customized snippet call, see Examples below.

Parameters

All of the parameters are separated in to categories according to their purpose.

Required

  • &getFolder - comma delimited list of directories
    • default: null
    • example: assets/snippets/filedownload
    • This parameter is used to specify which directories to display with the snippet. Multiple directories can be specified by seperating them with a comma. When specifying multiple directories the directory browsing functionality is no longer available. When typing a path do not include a trailing '/'.

Optional

  • &browseDirectories - [ 1 | 0 ]
    • default: 0
    • Allows users to view subdirectories of the directory specified with the getFolder parameter. When using this feature the following templates get used: parent, folder.
  • &groupByDirectory - [ 1 | 0 ]
    • default: 0
    • When multiple directories are specified in the getFolder parameter, this parameter will group the files by folder. When grouped by folder, the directory template is used to output the path above each group.
  • &getFile - string
    • default: null
    • example: filedownload.php
    • Makes the snippet output only the file specified. The getFolder parameter is still required and getFile should be a file inside of the directory. This allows for use of the download script and download counting with a single file.
  • &chkDesc - the name of a chunk
    • default: null
    • example: fileDescription
    • The chkDesc parameter allows descriptions to be added to the file listing included in a chunk. All of the files and descriptions should be listed in the chunk using the following format: path to file/filename|description|| for example:
    • chunk name: fileDescription
    • chunk content:

   assets/snippets/filedownload/test.pdf|This is a test pdf. It shows report stuff.||
   assets/snippets/filedownload/options.gif|These are the options available to you.||

Permissions

It is possible to restrict file downloads to certain web user groups using the parameters below.

  • &downloadGroups - comma delimited list of web user groups
    • default: null
    • example: Registered Users,Admin
    • Makes the download link active for users that belong to the specified groups. If a user is not logged in they will receive a JavaScript alert with the message contained in the noDownload language setting. Multiple groups can be specified by using a comma delimited list.
  • &deleteGroups - comma delimited list of web user groups
    • default: null
    • example: Admin
    • Allows the specified web user groups to delete files from the listing. The link will only be displayed for users that are logged in and in the specified web user group.

Download Counting

  • &countDownloads - [ 1 | 0 ]
    • default: 1
  • &useDbCount - [ 1 | 0 ]
    • default: 1
  • &skipTableCheck - [ 1 | 0 ]
    • default: 0

Images

  • &imgLocat - path to images
    • default: null
    • example: assets/images/icons
    • Holds the path to the images to associate with each file extension. The images will be outputted with [+fd.image+] placeholder.
  • &imgTypes - name of a chunk
    • default: null
    • Allows for associations between file extensions and an image. The information on these associations should be put into a chunk similar to the example below. Associations should be in a comma delimited list with an equal sign between the extension and the image name. The parent extension is used for getting the image for the parent folder link when using directory browsing. The folder extension is used for getting the image to associate with a directory. The default extension is applied to all files with extensions not specified in the chunk.

Template & Style

  • &tplList - name of chunk
    • default: see below
    • The templating for filedownload is all handled with one chunk. This chunk is split into seven sections: header, parent, folder, file, delete link, group by, and footer. All of these sections should be in the chunk template even if they are not all being used or it will not be processed correctly.
  • &splitter - string from tplList chunk
    • default: <!-- Fd:Splitter -->
    • The splitter parameter should be set to the string used to seperate your templates in the chunk. If the default splitter is used or the default template is used this does not need changed.
  • &altCss - string
    • default: fd-alt
    • This parameter specifies the class that will be applied to every other file/folder so a ledger look can be styled.
  • &firstFolderCss - string
    • default: null
    • This parameter specifies the class that will be applied to the first folder.
  • &lastFolderCss - string
    • default: null
    • This parameter specifies the class that will be applied to the last folder.
  • &firstFileCss - string
    • default: null
    • This parameter specifies the class that will be applied to the first file.
  • &lastFileCss - string
    • default: null
    • This parameter specifies the class that will be applied to the last file.
  • &folderCss - string
    • default: fd-folder
    • This parameter specifies the class that will be applied to all folders.
  • &fileCss - string
    • default: fd-file
    • This parameter specifies the class that will be applied to all files.
  • &parentCss - string
    • default: fd-parent
    • This parameter specifies the class that will be applied to the parent item.
  • &directoryCss - string
    • default: fd-directory
    • This parameter specifies the class that will be applied to the directory for multi-folder grouping.
  • &pathCss - string
    • default: fd-path
    • This parameter specifies the class that will be applied to the path when using directory browsing.
  • &extCss - [ 1 | 0 ]
    • default: 0
    • With this parameter set to 1 a class will be added to each file with the file's extension. For example, a pdf would get the class: fd-pdf.

Language

  • TO BE DONE

Examples

TO BE DONE

Resources

Personal tools