Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Creating funtion to list out all PDF's in a media folder

$
0
0
For the Razor function, you can have something like this:
@inherits RazorFunction

@functions {
    public override string FunctionDescription
    {
        get { return "A function that lists PDF downloads."; }
    }

    [FunctionParameter(Label="Folder")]
    public DataReference<IMediaFileFolder> folderWithPDF { get; set; }
}

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
    <div>
        @if (folderWithPDF != null)
        {
            <ul>
                @foreach (var pdfFile in Data.Get<IMediaFile>().Where(p => p.FolderPath == folderWithPDF.Data.Path))
                {
                    <li>
                        @pdfFile.Title
                        <br />
                        <a href="~/media(@pdfFile.Id)">Download</a>
                    </li>  
                }
            </ul>
        }
    </div>
</body>
</html>

Viewing all articles
Browse latest Browse all 2540

Trending Articles