Code example list files in folder

Render a list of files from a folder as an HTML table — filename, modified date, and a download link. The pattern is built on the getpages()-loop in a .hash-template, and works equally well for current-folder listings (request.folderpath) or any specific path. Use it for download pages, recent-documents widgets, or any content-driven file index.

Code for listing files in current folder

<table class="table table-striped" style="width:auto">
    <thead>
        <tr>
            <th>Filnavn</th>
            <th>Dato</th>
            <th>Last ned</th>
        </tr>
    </thead>
    <tbody data-loop="sortdesc(getpages(request.folderpath),'Title')" data="#">
        <tr>
            <td>
                #this.Title#
            </td>
            <td>
                #this.Modified#
            </td>
            <td>
                <a href="#request.filepath#/#this.filename#">Last ned</a>
            </td>
        </tr>
    </tbody>
</table>

Listing files from a specific folder

<table class="table table-striped" style="width:auto">
    <thead>
        <tr>
            <th>Filnavn</th>
            <th>Dato</th>
            <th>Last ned</th>
        </tr>
    </thead>
    <tbody data-loop="sortdesc(getpages('folderpath/subfolder'),'PublishDate')" data="#">
        <tr>
            <td>
                #this.Title#
            </td>
            <td>
                #this.Modified#
            </td>
            <td>
                <a href="#request.filepath#/#this.filename#">Last ned</a>
            </td>
        </tr>
    </tbody>
</table>