Jobs with Job Type (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, Topic(s), 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, as well as the "Job Types" Category. The instructions are included in the beginning of the code as comments. If you add this code to a page, it can be your "Job Postings" or "Classifieds" 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, Topic(s), 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, as well as the "Job Types" Category. -->
<!--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 with Job Types.-->
<!--A column on the right side allows your visitors to filter by job type.-->


<!--**IMPORTANT INFORMATION**-->


<!--To use this code you MUST have an existing "Job Postings" View and a "Job Posting Types" Category.-->


<!--1 - To create and edit 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.-->
    
<!--    Now that you're inside the View, click the "Document Map" dropdown list, -->
<!--    scroll down to find "FieldSet ArticleFields" and click it (do not click the black "x" circle).-->
<!--    In the code, you'll see the following new line:-->
    
<!--    <FieldSet Id="ArticleFields"/>-->
    
<!--    Now replace that whole line with the content below:-->
    
<!--    <FieldSet Id="ArticleFields">-->
<!--      <Category Id="JobPostingTypes" CatType="Job Posting Types" Name="Position Type" Cmd="After:Keywords" />-->
<!--    </FieldSet>-->
    
<!--    If you've previously made edits to the View, all you need to do is include the <Category> line inside the "ArticleFields" fieldset.-->
    
<!--    Save the view and you're done.-->


<!--2 - To create the "JobPostingTypes" Category:-->


<!--    In the dashboard main menu, click Admin > Categories. Click the green "+New Category Type" button on the right, and name it "Job Posting Types".-->
<!--    Click save. You may now create your Job Posting Types.-->
<!--    Save your edits.-->




<div class="row">
    <div class="col-sm-3 order-sm-2">
        @BRT.CategoryList(tableId:"Content", viewId:"JobPostings", fieldId:"JobPostingTypes", 
        template: 
        @<div class="topic-list-wrap">
            <h4 class="topic-list">Topics</h4>
            <p><a href="/jobs">All</a></p>
            @foreach(EngineRecord c in item) {
                <p><a href="/jobs?topic=@c["Id"]">@c["Label"]</a></p>
            }
        </div>)
    </div>
    <div class="col-sm-9">
        @BRT.Lister(tableId: "Content", viewId: "JobPostings",
        fields: new[] {"PrimaryImage","Title","PubDate","Authors.FirstName","Authors.LastName","Authors.PrimaryImage","Summary","Body","JobPostingTypes","Link"},
        condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[JobPostingTypes.Id]='" + Request.QueryString["topic"] + "'")),
        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>
                        }
                        @if (!record.IsDBNull("JobPostingTypes") && record.GetCategory("JobPostingTypes").Count > 0) {
                            <div class="topics">
                                @foreach(CategoryFieldItem topic in record.GetCategory("JobPostingTypes")) {
                                    <span>@topic.Label</span>
                                }
                            </div>
                        }
                    </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>)
    </div>
</div>
<br>