Files Helper

Last Updated 3/3/2015
List files in any of the Files directories

Add this in @BRT.Files(directory:"photo_galleries/somegallery")

and it will create a list of files.

Required parameter include:

  • directory (string) - You can find the directory's full name by going to files, select show properties. The value you want is found after name:

Optional parameters include:

  • template (Razor template) - Customize the layout of the files. Reference the code below.
  • showDirectories (boolean) - Shows a listing of all child directories above any files.
  • sortField (string) - Sort order for the files. Choose "Title" (order by title or filename ascending) or "Date" (order by date modified, descending); the default is "Title".

Default Code

@BRT.Files(directory:"documents/brochures")

Example
 

Using a Template

You can use a template to format the fiels helper to fit your needs. You will need to to loop through the list of  EnginePages.PhotoGalleryHelperExtensions.DirectoryFile in the item to access the file properties.

The following properties are available for files

Title
String. The title of the file or directory.

Filename
String. The filename of the file or directory

Description
String. Description of the file or directory

URL
String. The relative URL or he directory or file

IsDirectory
Boolean. Returns true if the file is a directory and false if it is a file

Image
A URL for images with the height and width set in the URL

DateCreated
The date the file or directory was created

Navigating Directories

You can navigate to another directory by using the dir QueryString.

Templated Code

@BRT.Files(directory:"photo_galleries/annual_conference_2013",showDirectories: true, sortField:"Date", template:
@<div>
     @foreach(EnginePages.PhotoGalleryHelperExtensions.DirectoryFile file in item) {
         if(file.IsDirectory == true) {
             <h3><i class="folder"></i> <a href="?dir=@file.URL">
                  @if (file.Title==""){
                       @file.Filename
                  }
                  else {
                       @file.Title
                  }     
             </a></h3>
             <p>@file.Description</p> 
         }
         else {  
             <div>
                  <p> 
                       <i class="file"></i> <a href="@file.URL" target="_blank">
                            @if (file.Title==""){
                                 @file.Filename
                            }
                            else {
                                 @file.Title
                            } 
                       </a><br/>
                       <span class="text-muted">@(file.DateCreated.Substring(4, 2) + "/" + file.DateCreated.Substring(6, 2)  + "/" +   file.DateCreated.Substring(0, 4)) </span><br/>
                       <span>@file.Description</span>
                   </p>
              </div>   
          }
     }
</div>)

Article Topics

For Developers

Want to learn more?

Call 800-924-5220 or

Free trial