Jobs (Lister Page)

<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a Jobs Lister containing Date, Primary Image (if present), -->
<!--and Summary (in the absence of Summary, it loads partial content of the Body). -->
<!--The Jobs View doesn't exist so you'll have to create it. The instructions are below. -->
<!--If you add this code to a page, it can be your "Job Postings" or "Classifieds" page.-->

<!--This code block loads Jobs lister page.-->

<!--** To use this page you must have an existing "Job Postings" View.**-->

<!--To create the View:-->

<!--In the dashboard main menu, click Admin > Views. You'll see a list of your existing views. -->
<!--If you don't see the "JobPostings" view, don't worry - we can create it easily.-->
<!--Click the green "+New" button on the right side and select "I'd like to create a new type of Content". -->
<!--Enter the name "Job Postings" (without the quote marks) and click Create.-->

<!--Save the view and you're done.-->


@BRT.Lister(tableId: "Content", viewId: "JobPostings",
fields: new[] {"PrimaryImage","Title","PubDate","Summary","Body","Link"},
template:
@<div>
  @foreach(EngineRecord record in item) {
    <article class="media">
        @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0) {
            if(record.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                if(!record.IsDBNull("Link")) {
                    <a href="@record["Link"]" target="_blank">
                        <img src="@(record.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(record.GetFiles("PrimaryImage")[0].Title) ? record.GetFiles("PrimaryImage")[0].Filename : record.GetFiles("PrimaryImage")[0].Title)"/>
                    </a>
                } else {
                    <a href="/job/@record.Href">
                        <img src="@(record.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(record.GetFiles("PrimaryImage")[0].Title) ? record.GetFiles("PrimaryImage")[0].Filename : record.GetFiles("PrimaryImage")[0].Title)"/>
                    </a>
                }
            }
        }
        <div class="media-body">
            <h5 class="mt-0 mb-0">
                <a href="/job/@record.Href">
                    @if(!record.IsDBNull("Title")) {
                      @record["Title"]
                    }
                </a>
            </h5>
            <small class="media-metadata text-muted">
                @if(!record.IsDBNull("PubDate")) {
                  <span>@record.GetDateTime("PubDate").ToShortDateString()</span>
                }
                @if(!record.IsDBNull("PubDate") && (!record.IsDBNull("JobPostingTypes") && record.GetCategory("JobPostingTypes").Count > 0)){
                    <span> - </span>
                }
            </small>
            @if(!record.IsDBNull("Summary")) {
                <p>@BRT.Raw(@record.GetString("Summary").Summarize(250))</p>
            } else {
                <p>@BRT.Raw(@record.GetString("Body").Summarize(250))</p>
            }
        </div>   
    </article>
    }
</div>)