primary_only=”“¶
Limit the results to only the primary files.
- Options: yes | no
- Default: no
{exp:channel_files:files}
<!-- Template Code -->
{/exp:channel_files:files}
This template tag allows you to show all files within a single entry.
Entry ID of an Channel Entry. Use this parameter to limit the files list to a specific entry.
Same as entry_id=”” but now it with the entry’s url_title.
Limit the files list to a specific Channel.
Same as channel=”” but uses channel_id’s instead.
Limit the files list to a specific category as chosen in the Fieldtype.
File ID of an file. Use this parameter to limit the files list to a specific file.
The “order” parameter sets the display order of the files. Setting options for this parameter include:
Default: orderby=”file_order”
The sort order can be ascending or descending. Setting options for this parameter include: - sort=”asc” - sort=”desc”
Default: sort=”asc’
This parameter limits the number of files on any given page. The limit will default to 30 entries if a value is not specified. If you are using pagination then this will determine the number of entries shown per page.
Default: limit=”30”
This parameter offsets the display by X number of entries. For example, if you want to show all entries except the three latest ones, you would do this: offset=”3”
Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. For example, if you put a <br /> tag after each entry you’ll have this:
Item 1<br /> Item 2<br /> Item 3<br />
You might, however, not want the <br /> tag after the final item. Simply count the number of characters (including spaces and line breaks) you want to remove and add the backspace parameter to the tag. The <br /> tag has 6 characters plus a new line character, so you would do this:
backspace=”7”
Would produce this:
Item 1<br /> Item 2<br /> Item 3
This parameter allows you to change the default variable prefix used. This is especially useful when you are nesting tags to avoid variable collisions.
Default: prefix=”file”
For example the default variable for the file URL is: {file:url} but if you use prefix=”cf” the variable for the file URL will now be {cf:url}
The full URL to the original file
Same as {file:url} but a HTTPS version
Obfuscated time limited url to the file
The file title as specified in the field row
The file description as specified in the field row
File category (if used/specified)
Shows the date/time of the upload For date variable info see: http://expressionengine.com/user_guide/templates/date_variable_formatting.html
Deprecated since version 5.0.1: Use {file:upload_date} instead.
Shows the date/time of the upload For date variable info see: http://expressionengine.com/user_guide/templates/date_variable_formatting.html
The filename of the file
The file extension of the file
The file size. Outputs for example: 2.3 MB
The file size, but now in bytes
The official mime-type of the file Example: image/jpeg
This variable permits you to rotate through any number of values as the entries are displayed. The first file will use “option_one”, the second will use “option_two”, the third “option_three”, the fourth “option_one”, and so on.
The most straightforward use for this would be to alternate colors. It could be used like so:
{exp:channel_files:files entry_id="{entry_id}"}
<div class="{switch='one|two'}">
<h2>{file:title}</h2>
<a href="{file:url}">{file:filename} ({file:filesize})</a>
</div>
{/exp:channel_files:files}
The files would then alternate between <div class=”one”> and <div class=”two”>.
Multiple instances of the {file:switch=} tag may be used and the system will intelligently keep track of each one.
The “count” out of the current files being displayed. If five files are being displayed, then for the fourth file the {file:count} variable would have a value of “4”.
The total number of files being displayed.
The contents of custom field 1
The contents of custom field 2
The contents of custom field 3
The contents of custom field 4
The contents of custom field 5
This tag will conditionally display the code inside the tag if there are no files
{exp:channel:entries channel="about"}
<h1>{title</h1>
<h2>All Files</h2>
{exp:channel_files:files entry_id="{entry_id}"}
<a href="{file:locked_url}" title="{file:title}">{file:title}</a>
{/exp:channel_files:files}
{/exp:channel:entries}
The pagination feature allows you to display a limited number of files and then automatically link to the next set. That way you can, for example, show files 1-10 on the first page and automatically link to pages that display 11-20, 21-30, etc
You have two choices as to the style of the navigation element. The first method would look something like this:
Page 27 of 344 pages << First < 11 12 13 14 15 > Last >>
The second method is a more traditional “next page” / “previous page” output:
Previous Page | Next Page
paginate="top" paginate="bottom" paginate="both"
This parameter is for use with files pagination and determines where the pagination code will appear for your files:
| Value | Description |
|---|---|
| top | The navigation text and links will appear above your list of entries. |
| bottom | The navigation text and links will appear below your list of entries. |
| both | The navigation text and links will appear both above and below your list of entries. |
If no parameter is specified, the navigation block will default to the “bottom” behavior.
This tells ExpressionEngine to override the normal pagination link locations and point instead to the explicitly stated template group and template. For example: paginate_base=”files/list”
These individual variables are for use inside the {file:paginate} tag pair.
Outputs the current page number (In the {file:paginate} tag pair)
The total number of pages of you have (In the {file:paginate} tag pair)
These show the current page you are on as well as “surrounding” pages in addition to links for nex/previous pages and first/last pages. (In the {file:paginate} tag pair)
These individual conditional variables are for use inside the {file:paginate} tag pair.
This tag will conditionally display the code inside the tag if there is a “next” page. If there is no next page then the content simply will not be displayed. (In the {file:paginate} tag pair)
This tag will conditionally display the code inside the tag if there is a “previous” page. If there is no previous page then the content simply will not be displayed. (In the {file:paginate} tag pair)