Job with Job Type and Related Content (Detail Page)

A Detail page is a template to be used for a particular type of content. This code creates a Job Detail page that will be used to display each of your Job Posts. It includes Date, Job Type, Primary Image (if present), Body, Primary Contact information, attached Files (if present), and Related Content (News and Photo Albums). The Jobs View doesn't exist so you'll have to create it as well as the Job Type Category. The instructions are included in the beginning of the code as comments.

<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Job Detail page that will be used to display each of your Job Posts. -->
<!--It includes Date, Job Type, Primary Image (if present), Body, Primary Contact information, -->
<!--attached Files (if present), and Related Content (News and Photo Albums). -->
<!--The Jobs View doesn't exist so you'll have to create it as well as the Job Type Category. -->
<!--The instructions are below.-->


<!--This code block loads a Job Post article with Job Posting Type and related content (in this order): -->
<!--News, Photo Albums.-->


<!--**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" />-->
<!--      <Relationship Id="RelatedNews" Name="Related News Articles" TableId="Content" ViewId="News" ShowAsTable="true" />-->
<!--      <Relationship Id="RelatedAlbums" Name="Related Photo Albums" TableId="Content" ViewId="PhotoAlbums" ShowAsTable="true" />-->
<!--    </FieldSet>-->
    
<!--    If you've previously made edits to the View, all you need to do is include the <Relationship> and <Category> lines 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 Postings types.-->
<!--    Save your edits.-->






@BRT.Detail(tableId: "Content", viewId: "JobPostings",
fields: new[] {"Title","PubDate","PrimaryImage","Body","JobPostingTypes","PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files",
"RelatedNews.Title","RelatedNews.PrimaryImage","RelatedNews.PubDate","RelatedNews.Summary","RelatedNews.Body","RelatedNews.Topic","RelatedNews.Link",
"RelatedAlbums.Title","RelatedAlbums.PrimaryImage","RelatedAlbums.Summary","RelatedAlbums.Body","RelatedAlbums.PhotoAlbumTopics"},
template:
@<article class="detailpage">
    <div>
        <small class="text-muted">
            @if(!item.IsDBNull("PubDate")) {
                <span>@item.GetDateTime("PubDate").ToString("MMMM dd, yyyy")</span>
            } 
            @if((!item.IsDBNull("PubDate")) && (!item.IsDBNull("JobPostingTypes")) && item.GetCategory("JobPostingTypes").Count > 0) {
                <span> - </span>
            }
            @if (!item.IsDBNull("JobPostingTypes") && item.GetCategory("JobPostingTypes").Count > 0) {
                <div class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("JobPostingTypes")) {
                        <span>@topic.Label</span>
                    }
                </div>
            }
        </small>
    </div>
    @if(!item.IsDBNull("PrimaryImage")) {
        <div class="primaryImg">
            @if(item.GetFiles("PrimaryImage").Count == 1){
                if(item.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                        <figure class="figure figure-fullwidth">
                            <img src="@(item.GetFiles("PrimaryImage")[0].Url)?width=1070&height=300&mode=crop" class="img-fluid" />
                            @*
                            <figcaption class="figure-caption"><em>@item.GetFiles("PrimaryImage")[0].Title</em>
                                <p>@item.GetFiles("PrimaryImage")[0].Description</p>
                            </figcaption>
                            *@
                        </figure>
                    }
            } else {
                <div class="in-page-carousel">
                    @foreach(FileFieldItem file in item.GetFiles("PrimaryImage")) {
                        if(file.ContentType.StartsWith("image/")) {
                            <figure class="figure figure-fullwidth">
                                <img src="@(file.Url)?width=1070&height=300&mode=crop" class="img-fluid" />
                                <figcaption class="figure-caption"><em>@file.Title</em>
                                    <p>@file.Description</p>
                                </figcaption>
                            </figure>
                        }
                    }
                </div>
            }
        </div>
    }
    <div>@BRT.Raw(@item.GetString("Body"))</div>
    <div>
        @if(!item.IsDBNull("PrimaryContact")) {
            <div class="box box-outline">
                <h4>Contact Information</h4>
                <h5>@item["PrimaryContact"]</h5>
                @if(!item.IsDBNull("Location")) {
                  <p>@item["Location"]</p>
                }
                @if(!item.IsDBNull("Address1")) {
                    <p>
                        <span>@item["Address1"]</span>
                        @if(!item.IsDBNull("Address2")) {
                            <span>, @item["Address2"]</span>
                        }
                    </p>
                }
                @if(!item.IsDBNull("City")) {
                    <span>@item["City"]</span>
                }
                @if(!item.IsDBNull("State")) {
                    foreach(CategoryFieldItem cat in item.GetCategory("State")) {
                        <span>@cat.Label</span>
                    }
                }
                @if(!item.IsDBNull("Zip")) {
                    <span>@item["Zip"]</span>
                }
                @if(!item.IsDBNull("Phone")) {
                    <p>@item["Phone"]</p>
                }
                @if(!item.IsDBNull("Email")) {
                    <p><a href="mailto:@item["Email"]">@item["Email"]</a></p>
                }
            </div>
        }
        @if(!item.IsDBNull("Files") && item.GetFiles("Files").Count > 0) {
            <div class="box box-outline">
                <h4>Files</h4>
                @foreach(FileFieldItem file in item.GetFiles("Files")) {
                    if(file.ContentType.StartsWith("image/")) {
                        <p><a href="@file.Url" target="_blank">@(String.IsNullOrEmpty(file.Title) ? file.Filename : file.Title) <i class="fas fa-file-image"></i></a></p>
                    } else {
                        <p><a href="@file.Url" target="_blank">@(String.IsNullOrEmpty(file.Title) ? file.Filename : file.Title) <i class="fas fa-external-link-square-alt"></i></a></p>
                    }
                }
            </div>
        }
    </div>
    <!--RELATED NEWS-->
    @if(!item.IsDBNull("RelatedNews") && (item.GetRecordList("RelatedNews").Count > 0)) {
        <div class="box box-outline">
            <h4>Related News</h4>
            @foreach(EngineRecord item_relatednews in item.GetRecordList("RelatedNews")) {
                <article class="media">
                    @if(!item_relatednews.IsDBNull("PrimaryImage") && item_relatednews.GetFiles("PrimaryImage").Count > 0) {
                        if(item_relatednews.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            if(!item_relatednews.IsDBNull("Link")) {
                                <a href="@item_relatednews["Link"]" target="_blank">
                                    <img src="@(item_relatednews.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(item_relatednews.GetFiles("PrimaryImage")[0].Title) ? item_relatednews.GetFiles("PrimaryImage")[0].Filename : item_relatednews.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            } else {
                                <a href="/article/@item_relatednews.Href">
                                    <img src="@(item_relatednews.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(item_relatednews.GetFiles("PrimaryImage")[0].Title) ? item_relatednews.GetFiles("PrimaryImage")[0].Filename : item_relatednews.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            @if(item_relatednews.IsDBNull("Link")) {
                                <a href="/article/@item_relatednews.Href">
                                    @item_relatednews["Title"]
                                </a>
                            } else {
                                <a href="@item_relatednews["Link"]">
                                    @item_relatednews["Title"]
                                </a>
                            }
                        </h5>
                        <small class="media-metadata text-muted">
                            @if(!item_relatednews.IsDBNull("PubDate")) {
                              <span>@item_relatednews.GetDateTime("PubDate").ToShortDateString()</span>
                            }
                            @if(!item_relatednews.IsDBNull("PubDate") && !item_relatednews.IsDBNull("Topic")){
                                <span> | </span>
                            }
                            @if (!item_relatednews.IsDBNull("Topic") && item_relatednews.GetCategory("Topic").Count > 0) {
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in item_relatednews.GetCategory("Topic")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            }
                        </small>
                        @if(!item_relatednews.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@item_relatednews.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@item_relatednews.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
    <!--RELATED PHOTO ALBUMS-->
    @if(!item.IsDBNull("RelatedAlbums") && (item.GetRecordList("RelatedAlbums").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Albums</h4>
            @foreach(EngineRecord relatedAlbum in item.GetRecordList("RelatedAlbums")) {
                <article class="media">
                    @if(!relatedAlbum.IsDBNull("PrimaryImage") && relatedAlbum.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedAlbum.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/album/@relatedAlbum.Href">
                                <img src="@(relatedAlbum.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedAlbum.GetFiles("PrimaryImage")[0].Title) ? relatedAlbum.GetFiles("PrimaryImage")[0].Filename : relatedAlbum.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/album/@relatedAlbum.Href">
                                @if(!relatedAlbum.IsDBNull("Title")) {
                                  @relatedAlbum["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if (!relatedAlbum.IsDBNull("Topic") && relatedAlbum.GetCategory("Topic").Count > 0) {
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedAlbum.GetCategory("Topic")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            }
                        </small>
                        @if(!relatedAlbum.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedAlbum.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedAlbum.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
</article>)


<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    })
</script>