Author (Detail Page)

A Detail page is a template to be used for a particular type of content. This code creates an Author Detail page that will be used to display your Authors' information. It includes the Author's Biography, Primary Image (if present), Email address, Social Media links, and Published Articles. In order to work with the Blog Posts Lister Page code block, the Friendly URL of this page should be "author".

<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates an Author Detail page that will be used to display your Authors' information. -->
<!--It includes the Author's Biography, Primary Image (if present), Email address, Social Media links, -->
<!--and Published Articles. In order to work with the Blog Posts Lister Page code block, -->
<!--the Friendly URL of this page should be "author".-->


<!--The Published Articles section of this code finds type of content between News and Blog Posts -->
<!--to call the correct detail page according to the type or article.-->


@section head {


    <style>
        .pagetitle {
            display: none;
        }
        .person-img {
            text-align: center;
            margin-bottom: 30px;
        }
    </style>
}


@BRT.Detail(tableId: "Contacts", viewId: "Authors",
fields: new[] {"Category","PrimaryImage","FirstName","PreferredName","LastName",
"Email","Phone1","Phone2","Phone3","MailAddress1","MailAddress2","MailCity","MailState","MailZip","MailCountry","Files",
"Description","Links.Type","Links.Link","Articles.Category","Articles.Title","Articles.PubDate","Articles.PrimaryImage","Articles.Summary","Articles.Body","Articles.Link"},
template:
@<div class="row">
    <div class="col-12 col-lg-8">
        <div class="customtitle">
            <h1>
                @if(!item.IsDBNull("PreferredName")) {
                    <span>@item["PreferredName"]</span>
                    <small class="text-muted">
                        @if(!item.IsDBNull("FirstName")) {
                            <span>@item["FirstName"]</span>
                        }
                        @if(!item.IsDBNull("LastName")) {
                            <span>@item["LastName"]</span>
                        }
                    </small>
                } else {
                    if(!item.IsDBNull("FirstName")) {
                        <span>@item["FirstName"]</span>
                    }
                    if(!item.IsDBNull("LastName")) {
                        <span>@item["LastName"]</span>
                    }
                }
            </h1>
        </div>
        @if(!item.IsDBNull("Description")) {
            <span>@BRT.Raw(@item["Description"])</span>
        }
    </div>
    <div class="col-12 col-lg-4">
        @if(!item.IsDBNull("PrimaryImage") && item.GetFiles("PrimaryImage").Count > 0) {
            if(item.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                <div class="person-img"><img src="@(item.GetFiles("PrimaryImage")[0].Url)?width=350&height=350&mode=crop" class="img-fluid" alt="@(String.IsNullOrEmpty(item.GetFiles("PrimaryImage")[0].Title) ? item.GetFiles("PrimaryImage")[0].Filename : item.GetFiles("PrimaryImage")[0].Title)"/></div>
            }
        }
        @if(!item.IsDBNull("Email")) {
            <span><a href="mailto:@item["Email"]" target="_blank" class="email" data-toggle="tooltip" title="Email">@item["Email"]</a></span>
        }
        @if(!item.IsDBNull("Links") && item.GetRecordList("Links").Count > 0) {
            <div class="social">
                <!--<h5>Links</h5>-->
                <center>
                    @foreach(EngineRecord item_links in item.GetRecordList("Links")) {
                        if(!item_links.IsDBNull("Type")) {
                            if(!item_links.IsDBNull("Link")) {
                                <span>
                                    <a href="@item_links["Link"]" class="@item_links.GetCategory("Type")[0].Label.ToLower()" target="_blank" data-toggle="tooltip" title="@item_links.GetCategory("Type")[0].Label" ></a>
                                </span>
                            }
                        } else {
                            if(!item_links.IsDBNull("Link")) {
                                <span>
                                    <a href="@item_links["Link"]" class="website" target="_blank" data-toggle="tooltip" title="Link"></a>
                                </span>
                            }
                        }
                    }
                </center>
            </div>
        }
        
        <br/>
        <div>
            <h5>Published Articles</h5> 
            @if(!item.IsDBNull("Articles")) {
                int i = 0;
                string detailpage = null;
                foreach(EngineRecord item_articles in item.GetRecordList("Articles")) {
                    if (i < 6){
                        i++;    
                        foreach(CategoryFieldItem cat in item_articles.GetCategory("Category")) {
                            detailpage = @cat.Label;
                        }
                        switch (detailpage) {
                            case "News":
                                detailpage = "article";
                                break;
                            case "Blog Posts":
                                detailpage = "post";
                                break;
                            case "Recipes":
                                detailpage = "recipe";
                                break;
                            default:
                                break;
                        }
                        if(!item_articles.IsDBNull("Title")) {
                            <p>
                                @if(!item_articles.IsDBNull("PubDate")) {
                                  <small>@item_articles.GetDateTime("PubDate").ToShortDateString() - </small>
                                }
                                <a href="/@detailpage/@item_articles.Href">@item_articles["Title"]</a>
                            </p>
                        }
                    }
                    
                }
            }
        </div>
    </div>
    <div class="col-12">
        @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>
</div>)
<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    })
</script>