Brick River Code Snippets

***********UPDATING AN ADAPTER RECORD ***************

	    EngineAdapter ad = EngineAdapter.Create("Contacts","Counselors"); 
            ad.AddResultField("HideOnline");
	   // or ad.AddResultFields(new[] {"FieldsHere"})
            
            EngineRecord counselor = ad.GetRecord(Convert.ToInt32(Request.UrlSegments[0]));
            counselor["HideOnline"] = true;
            counselor.Update();


**************Inserting AN ADAPTER RECORD****************

EngineAdapter ad = EngineAdapter.Create("Content","NomineeReferences"); 
                ad.AddResultFields(new[] {"PastorName", "Email", "Nominee"});
                EngineRecord refp = ad.CreateNewRecord();
                refp["PastorName"] = req.GetString("Pastor");
                refp["Email"] = req.GetString("PastorEmail");
                refp["Nominee"] = new[] {Convert.ToInt32(Request.UrlSegments[0])};
                refp.Insert();
            
ADD CATEGORY VALUE IN ADAPTER**********

s["ClergyStatus"]= new CategoryFieldValue(new[] {cs.Value});

CHECK IF RECORD EXISTS
bool doesExists = ad.RecordsExist()
                        
<!--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>
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Post Detail page that will be used to display each of your Blog Posts. -->
<!--It includes Date, Author(s) Name, Topic(s), Primary Image (if present), the content of the Post, -->
<!--attached Files (if present), and Author(s) (in a more detailed manner, as opposed to the previously displayed Author(s) name). -->
<!--In order to work with the Blog Posts Lister Page code block, the Friendly URL of this page should be "post".-->


<!--This code block creates a blog post page including author(s) info (if present) and topics.-->

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

<!--To use this code you MUST do the following:-->

<!--In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > slick-->
    
<!--    Download the following files and upload them to the "slick" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/ajax-loader.gif-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick-carousel.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.min.js-->

@section head {
    
    <link href="/files/content/www/slick/slick.css" rel="stylesheet"/>
    <link href="/files/content/www/slick/slick-carousel.css" rel="stylesheet"/>

    <style>
        .media-metadata {
            margin-bottom: 30px;
        }
        
        .media-metadata .topics > span:not(:last-child):after {
            content: " | ";
        }
    </style>
}

@BRT.Detail(tableId: "Content", viewId: "BlogPosts",
fields: new[] {"PrimaryImage","Title","PubDate",
"Summary","Body","Topic","Files",
"Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
"Authors.NameSuffix","Authors.DoNotEmail","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link"},
template:
@<article class="detailpage">
    <small>
        <div class="media-metadata text-muted">
            @if(!item.IsDBNull("PubDate")) {
              <span>@item.GetDateTime("PubDate").ToShortDateString()</span>
            }
            
            @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
                if(!item.IsDBNull("PubDate")){
                    <span> - </span>
                }
                <span>by: </span>
                <span class="topics">
                    @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                        <span>
                            <a href="/author/@item_authors.Href">
                                @if(!item_authors.IsDBNull("PreferredName")) {
                                    <span>@item_authors["PreferredName"]</span>
                                } else {
                                    <span>@item_authors["FirstName"]</span>
                                }
                                @if(!item_authors.IsDBNull("MiddleName")) {
                                    <span>@item_authors["MiddleName"]</span>
                                }
                                @if(!item_authors.IsDBNull("LastName")) {
                                    <span>@item_authors["LastName"]</span>
                                }
                                @if(!item_authors.IsDBNull("NameSuffix")) {
                                    <span>@item_authors["NameSuffix"]</span>
                                }
                            </a>
                        </span>
                    }
                </span>
            }
            @if (!item.IsDBNull("Topic") && item.GetCategory("Topic").Count > 0) {
                if((!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) || !item.IsDBNull("PubDate")) {
                    <span> - </span>
                }
                <span class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("Topic")) {
                        <span>@topic.Label</span>
                    }
                </span>
            }
        </div>
    </small>
    
    @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" />
                    </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>
    }
    @if(!item.IsDBNull("Body")) {
      <div>@BRT.Raw(@item.GetString("Body"))</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/")) {
                  <img src="@(file.Url)?width=200&height=200"/>
                } 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>
    }
    @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
        string authorCount = "Authors";
        if(item.GetRecordList("Authors").Count == 1) {
            authorCount = "Author";
        }
        <div class="box box-bg">
            <h4>@authorCount</h4>
            @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                <div class="media">
                    @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                        if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/author/@item_authors.Href">
                                <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5>
                            <a href="/author/@item_authors.Href">
                                @if(!item_authors.IsDBNull("PreferredName")) {
                                    <span>@item_authors["PreferredName"]</span>
                                } else {
                                    <span>@item_authors["FirstName"]</span>
                                }
                                @if(!item_authors.IsDBNull("MiddleName")) {
                                    <span>@item_authors["MiddleName"]</span>
                                }
                                @if(!item_authors.IsDBNull("LastName")) {
                                    <span>@item_authors["LastName"]</span>
                                }
                                @if(!item_authors.IsDBNull("NameSuffix")) {
                                    <span>@item_authors["NameSuffix"]</span>
                                }
                            </a>
                        </h5>
                        @if(!item_authors.IsDBNull("Description")) {
                            <p>@item_authors.GetString("Description").Summarize(250)</p>
                        }
                        <div class="social">
                            @if(!item_authors.IsDBNull("Email")) {
                                <span><a href="mailto:@item_authors["Email"]" class="email"
                                    data-toggle="tooltip" title="Email"
                                ></a></span>
                            }
                            @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                    if(!item_authors_links.IsDBNull("Type")) {
                                        if(!item_authors_links.IsDBNull("Link")) {
                                            <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                            ></a></span>
                                        }
                                    } else {
                                        if(!item_authors_links.IsDBNull("Link")) {
                                            <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                data-toggle="tooltip" title="Link" 
                                            ></a></span>
                                        }
                                    }
                                }
                            }
                        </div>
                    </div>
                </div>
            }
        </div>
    }
</article>)

<script src="/files/content/www/slick/slick.min.js"></script>
<script>
    // initialize carousel
    $('.in-page-carousel').slick({
        slidesToShow: 1
        , autoplay: false
        , dots: false
    });
    $(".slick-prev, .slick-next").text("");

</script>
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Post Detail page that will be used to display each of your Blog Posts. -->
<!--It includes select Related Content (News Articles and Photo Albums), therefore you must make edits to the BlogPosts View to use this code. -->
<!--The instructions are below. -->
<!--In order to work with the Blog Posts Lister Page code block, the Friendly URL of this page should be "post".-->

<!--This code block creates a blog post page including author(s) info (if present), related News and related Photo Albums.-->

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

<!--To use this code you MUST make the following edit to the "BlogPosts" View and make sure you have an existing Photo Albums View:-->

<!--In the dashboard main menu, click Admin > Views. You'll see a list of your existing views. -->
<!--If you don't see the "Blog Posts" view, don't worry - it exists, but you can't see it because you haven't made any edits to it yet.-->
<!--Click the green "+New" button on the right side and select "I'd like to customize an existing view". -->
<!--Select "Blog Posts (Content)" from the list.-->

<!--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">-->
<!--  <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> lines inside the "ArticleFields" fieldset.-->

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

@section head {
    <style>
        .media-metadata {
            margin-bottom: 30px;
        }
        
        .media-metadata .topics > span:not(:last-child):after {
            content: " | ";
        }
    </style>
}

@BRT.Detail(tableId: "Content", viewId: "BlogPosts",
fields: new[] {"PrimaryImage","Title","PubDate",
"Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
"Authors.NameSuffix","Authors.DoNotEmail","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link",
"RelatedNews.Title","RelatedNews.PrimaryImage","RelatedNews.PubDate","RelatedNews.Summary","RelatedNews.Body","RelatedNews.Topic","RelatedNews.Link",
"RelatedAlbums.Title","RelatedAlbums.PrimaryImage","RelatedAlbums.Summary","RelatedAlbums.Body","RelatedAlbums.PhotoAlbumTopics",
"Summary","Body","Topic","Files"},
template:
@<div>
    <small>
        <div class="media-metadata text-muted">
            @if(!item.IsDBNull("PubDate")) {
              <span>@item.GetDateTime("PubDate").ToShortDateString()</span>
            }
            @if(!item.IsDBNull("PubDate") && !item.IsDBNull("Authors")){
                <span> - </span>
            }
            @if(!item.IsDBNull("Authors")) {
              <span>by: </span>
              <span class="topics">
                  @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <span>
                        <a href="/author/@item_authors.Href">
                            @if(!item_authors.IsDBNull("FirstName")) {
                              <span>@item_authors["FirstName"]</span>
                            }
                            @if(!item_authors.IsDBNull("LastName")) {
                              <span>@item_authors["LastName"]</span>
                            }
                        </a>
                    </span>
                    }
              </span>
            }
            @if (!item.IsDBNull("Topic") && item.GetCategory("Topic").Count > 0) {
                <div class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("Topic")) {
                        <span>@topic.Label</span>
                    }
                </div>
            }
        </div>
    </small>
    
    @if(!item.IsDBNull("PrimaryImage")) {
      foreach(FileFieldItem file in item.GetFiles("PrimaryImage")) {
        if(file.ContentType.StartsWith("image/")) {
            <div class="primaryImg">
                <img src="@(file.Url)?width=1050&height=300" class="img-fluid"/>
            </div>
        }
      }
    }
    @if(!item.IsDBNull("Body")) {
      <div>@BRT.Raw(@item.GetString("Body"))</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/")) {
                  <img src="@(file.Url)?width=200&height=200"/>
                } 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>
    }
    @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
            string authorCount = "Authors";
            if(item.GetRecordList("Authors").Count == 1) {
                authorCount = "Author";
            }
            <div class="box box-bg">
                <h4>@authorCount</h4>
                @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <div class="media">
                        @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                            if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                                <a href="/author/@item_authors.Href">
                                    <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                        <div class="media-body">
                            <h5>
                                <a href="/author/@item_authors.Href">
                                    @if(!item_authors.IsDBNull("PreferredName")) {
                                        <span>@item_authors["PreferredName"]</span>
                                    } else {
                                        <span>@item_authors["FirstName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("MiddleName")) {
                                        <span>@item_authors["MiddleName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("LastName")) {
                                        <span>@item_authors["LastName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("NameSuffix")) {
                                        <span>@item_authors["NameSuffix"]</span>
                                    }
                                </a>
                            </h5>
                            @if(!item_authors.IsDBNull("Description")) {
                                <p>@item_authors.GetString("Description").Summarize(250)</p>
                            }
                            <div class="social">
                                @if(!item_authors.IsDBNull("Email")) {
                                    <span><a href="mailto:@item_authors["Email"]" class="email"
                                        data-toggle="tooltip" title="Email"
                                    ></a></span>
                                }
                                @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                    foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                        if(!item_authors_links.IsDBNull("Type")) {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                    data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                                ></a></span>
                                            }
                                        } else {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                    data-toggle="tooltip" title="Link" 
                                                ></a></span>
                                            }
                                        }
                                    }
                                }
                            </div>
                        </div>
                    </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")) {
                bool hasLink = false;
                if(!item_relatednews.IsDBNull("Link")){
                    hasLink = true;
                }
                <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(!hasLink) {
                                <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")) {
                                foreach(CategoryFieldItem topic in item_relatednews.GetCategory("Topic")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </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("PhotoAlbumTopics")) {
                                foreach(CategoryFieldItem topic in relatedAlbum.GetCategory("PhotoAlbumTopics")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </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>
    }
</div>)
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a Blogs Lister containing Date, Topic(s), Author(s), Primary Image (if present), -->
<!--and Summary (in the absence of Summary, it loads partial content of the Body). -->
<!--If you add this code to a page, it can be your "Blogs" page.-->

<!--This code block creates a Blog Posts lister page showing author(s) info (if present) and topics under title, right column loads topics for filtering.-->

@section head {
    <style>
        .media-metadata {
            margin-bottom: 30px;
        }
        
        .media-metadata .topics > span:not(:last-child):after {
            content: " | ";
        }
    </style>
}

<div class="row">
    <div class="col-sm-3 order-sm-2">
        @BRT.CategoryList(tableId:"Content", viewId:"BlogPosts", fieldId:"Topic", 
        template: 
        @<div class="topic-list-wrap">
            <h4 class="topic-list">Topics</h4>
            <p><a href="/blogs">All</a></p>
            @foreach(EngineRecord c in item) {
                <p><a href="/blogs?topic=@c["Id"]">@c["Label"]</a></p>
            }
        </div>)
    </div>
    <div class="col-sm-9">
        @BRT.Lister(tableId: "Content", viewId: "BlogPosts",
        fields: new[] {"Title","PubDate","Summary","Body","Topic","Link","PrimaryImage",
        "Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName","Authors.NameSuffix","Authors.PrimaryImage"},
        condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[Topic.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="/post/@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="/post/@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("Authors") && record.GetRecordList("Authors").Count > 0) {
                            if(!record.IsDBNull("PubDate")){
                                <span> - </span>
                            }
                          <span>by: </span>
                          <span class="topics">
                              @foreach(EngineRecord record_authors in record.GetRecordList("Authors")) {
                                <span>
                                    <a href="/author/@record_authors.Href">
                                        @if(!record_authors.IsDBNull("PreferredName")) {
                                            <span>@record_authors["PreferredName"]</span>
                                        } else {
                                            <span>@record_authors["FirstName"]</span>
                                        }
                                        @if(!record_authors.IsDBNull("MiddleName")) {
                                            <span>@record_authors["MiddleName"]</span>
                                        }
                                        @if(!record_authors.IsDBNull("LastName")) {
                                            <span>@record_authors["LastName"]</span>
                                        }
                                        @if(!record_authors.IsDBNull("NameSuffix")) {
                                            <span>@record_authors["NameSuffix"]</span>
                                        }
                                    </a>
                                </span>
                                }
                          </span>
                        }
                        @if (!record.IsDBNull("Topic") && record.GetCategory("Topic").Count > 0) {
                            if(!record.IsDBNull("Authors") || !record.IsDBNull("PubDate")){
                                <span> - </span>
                            }
                            <span class="topics">
                                @foreach(CategoryFieldItem topic in record.GetCategory("Topic")) {
                                    <span>@topic.Label</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>)
    </div>
</div>
                        
@*------------------ Wrap the calendar in a class---------------
<div class="brcalendar">
    @BRT.Calendar(DetailPage:"event")
</div>
*@

@*------------------ then put in this CSS ----------------------*@

@media (max-width: whateversize) {
    /* Force table to not be like tables anymore */
     .brcalendar table, .brcalendar thead, .brcalendar tbody, .brcalendar th, .brcalendar td, .brcalendar tr {
         display: block;
    }
    /* Hide table headers (but not display: none;
    , for accessibility) */
     .brcalendar thead tr {
         position: absolute;
         top: -9999px;
         left: -9999px;
         display:none;
    }
    /*tr {
         border: 1px solid #ccc;
    }
    */
     .brcalendar td {
        /* Behave like a "row" */
         border: none;
         border-bottom: 1px solid #ccc;
         position: relative;
        /*padding-left: 50%;
         */
         height:auto;
    }
     .brcalendar td:before {
        /* Now like a table header */
         position: absolute;
        /* Top/left values mimic padding */
         top: 6px;
         left: 6px;
         width: 45%;
         padding-right: 10px;
         white-space: nowrap;
    }
     .cal-header, table.cal > tr, .cal-day-unused {
         display:none !important;
    }
     .cal td {
         overflow:visible !important;
    }
     td.cal-day, td.cal-day-weekend {
         height:auto !important;
         font-size:1rem !important;
    }
}
                        
@BRT.Calendar(DetailPage: "",savedFilters: new[] {"Future"}, fields: new[] {"StartDate","Title", "Body"} ,
pageSize:5, 
template:                    
@<ul>
    @foreach(EngineRecord i in item) {
    <li>
        @if(!i.IsDBNull("StartDate")) {
        <div class="eventdate pull-left">@i.GetDateTime("StartDate").ToString("MMMM")<br/><span class="eventnumber">@i.GetDateTime("StartDate").Day</span></div>
        }
        <div class="listtitle"><a href="/eventdetail/@i.Href">@i["Title"]</a></div>
        <div>@i.GetString("Body").Summarize(200)</div>
        <div class="clearfix"></div>
    </li>
    }
</ul>
)
                        
@*
This spits out a CarouFredSel list of testimonials. Posted 5/26/2016 so ensure you have the latest of everything.
Here's the CarouFredSel website
https://dev7studios.com/products/caroufredsel-wordpress-plugin/


You have to put the call the jQuery file in the head
Put in @section head {
the script stuff below
}

*@

<script type="text/javascript" src="/files/content/www/owlcarousel/jquery.caroufredsel-6.2.1.js"></script>


<script type="text/javascript">
     
$(function() {
   
    $("#caro").carouFredSel({
        
        auto: 7000,
        scroll : {
            items: 1,
            pauseOnHover: true
        },
        pagination: {
            container: "#pager",
            keys: true
        },
        responsive: true,
        prev: {
            button: "#prev",
            pauseOnHover: true
        },
        next: {
            button: "#next",
    		pauseOnHover: true
    	}     
        
    });    

});
</script>


@*
Now here's the code that calls the carousel.
This is calling a carousel of testimonials
*@

<div id="caro">
    @BRT.Lister(tableId:"Content",viewId:"Testimonials",pageSize:10,fields: new[] {"Authors.PrimaryImage","Authors.FirstName","Authors.LastName","Summary","PubDate","PersonTitle","PersonName"}, 
    sortFields: new SortFieldMeta[] {new SortFieldMeta() {FieldId = "PubDate", Descending = true}},itemTemplate:
    @<div class="testimonial">
        <div class="testimonial-meat">
            @if(!item.IsDBNull("Authors") && @item.GetRecordList("Authors").Count > 0) {
                if (item.GetRecordList("Authors")[0].GetFiles("PrimaryImage").Count==1) {
                    <img class="test-img img-circle" src="@item.GetRecordList("Authors")[0].GetFiles("PrimaryImage")[0].Url?width=90&height=90&mode=crop&vert=top&sat=70" />
                }
            }
            <div>@item["Summary"]</div>
            <div><b>@item["PersonName"], @item["PersonTitle"]</b></div>
        </div>
        <p><a href="/testimonials">View all testimonials &rarr;</a></p>
    </div>)
</div>
<div class="clearfix"></div>
                        
@*------- begin code---------------------------
@{
    string thelink="";
    string ls="";
    string le="</a>";
    
    if(!item.IsDBNull("Link")){
        thelink = item.GetString("Link");
        if(!thelink.StartsWith("http://") && !thelink.StartsWith("https://")){
            thelink = "http://" + thelink;
        }
        ls = "<a href=\"" + thelink + "\" target=\"_blank\">";    
    }
    else{
        ls = "<a href=\"/post/" + item.Href + "\">";
    }
}
@if (item.GetFiles("PrimaryImage").Count>0) {
    <div class="mb-1">
        @BRT.Raw(ls)
        <img src="@item.GetFiles("PrimaryImage")[0].Url?width=316&height=110&mode=crop" />
        @BRT.Raw(le)
    </div>
} 
<div>
    @BRT.Raw(ls)
    <b>@item.GetString("Title")</b>
    @BRT.Raw(le)
</div>
end code--------------------------*@
                        
if(Request.HttpMethod == "POST" && !String.IsNullOrEmpty(Request.Form["email"])){

}
                        
@*-------------- start ---------------------------
@BRT.Lister(tableId:"Content", viewId:"Posts",pageSize: 4, fields: new[] {"Title", "PubDate", "Body","Summary", "PrimaryImage","Photos","Files"},
template:
@<div>
    @if(item.Count >= 1) {
        <div class="box">
            <h5>The title of the section goes here</h5>
            @foreach(EngineRecord record in item) {
                <div>Put your lister stuff in here</div> 
            }
        </div>
    }
</div>)
----------------- end ------------------------*@
                        
@*
<h4>@Site.GetRecordList("District")[0].GetString("Name"), other &quot;District&quot;, and &quot;Conference&quot; events</h4>

@BRT.Calendar(DetailPage: "event",savedFilters: new[] {"Future"}, fields: new[] {"StartDate","EndDate","Title","PrimaryImage","RelatedSites","Body","RegForms","RegForms.Friendly","Friendly"} ,
pageSize:5000, 
template:                    
@<div>
    
    @foreach(EngineRecord record in item) {
        string thelink = "";
        if(!@record.IsDBNull("RegForms")){
            thelink="https://mississippi-reg.brtapp.com/" + record.GetRecordList("RegForms")[0].GetString("Friendly");
        }
    
        
        <hr/>
        
        <h4><a href="/event/@record.Href"> 
            @if(!@record.IsDBNull("Title")){
                @record.GetString("Title")
            }
        </a></h4>
        
        if(!@record.IsDBNull("StartDate")){
            <p class="camp-date">
            <b>
            @if(record.GetDateTime("StartDate").ToString("h tt")!="12 AM") {
                @(record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) 
            }
            else {
                @(record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy")) 
            }
            </b>
            @if(!@record.IsDBNull("EndDate") && (record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy - h:mm tt")!=record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) ){
                <b> to 
            @if(record.GetDateTime("EndDate").ToString("h tt")!="12 AM") {
                @(record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) 
            }
            else {
                @(record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy")) 
            }
            </b>
            }
            </p>
        }
        if(!@record.IsDBNull("Body")){
            <p>@record.GetString("Body").Summarize()</p>
        }
        
    }
</div>
)
*@
                        
@* Simple short date format
@item.GetDateTime("PubDate").ToString("d")
*@

Go to this URL for more
https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1

@* ----------------------------------------
Here's a From To on event dates -----------

if(!@record.IsDBNull("StartDate")){
<p>
<b>
@if(record.GetDateTime("StartDate").ToString("h tt")!="12 AM") {
    @(record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) 
}
else {
    @(record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy")) 
}
</b>
@if(!@record.IsDBNull("EndDate") && (record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy - h:mm tt")!=record.GetDateTime("StartDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) ){
    <b> to 
@if(record.GetDateTime("EndDate").ToString("h tt")!="12 AM") {
    @(record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy - h:mm tt")) 
}
else {
    @(record.GetDateTime("EndDate").ToString("dddd, MMMM dd yyyy")) 
}
</b>
}
</p>
---------------- end --------------------
*@
                        
@using System.IO
@using System.Text

@functions{
   
    public override void InitializePage() {
        
        Response.ContentType = "text/csv";
        Response.Headers.Add("Content-Disposition","attachment;filename=" + Request.Friendly + ".csv");
        base.InitializePage();
      
    }
    
    public string GenerateCSV(string myData) {
        UnicodeEncoding uniEncoding = new UnicodeEncoding();
        
        using(MemoryStream ms = new MemoryStream()){
            var sw = new StreamWriter(ms, uniEncoding);
            sw.Write(myData);
        }
        
        return myData;
    }
    
  
    string People(EngineRecordList item){
        StringBuilder sb = new StringBuilder();

        sb.AppendLine("First Name,Last Name,Email");
        
        foreach(EngineRecord r in item){
            
            sb.Append("\"" + r.GetString("FirstName") + "\"");
            sb.Append(",\"" + r.GetString("LastName") + "\"");
            sb.Append(",\"" + r.GetString("Email") + "\"");
            sb.Append("\n");         
          
        }
        
        return sb.ToString();
    }
 
}   


@if(Request.Friendly == "peopledownload"){


    @BRT.Lister(tableId: "Contacts", viewId: "People",
    condition: "",
    fields: new[] {"FirstName","LastName","Email"},template:
    
         @<text>
                @BRT.Raw(GenerateCSV(People(item)))
         </text>
    ) 
     @RenderBody()
   }else{
    
      <html lang="en">
        <head>
            
        </head>
        <body>
           
            @RenderBody()
       
        </body>
    </html>
  
}
                        
int colno = 1;
int imgsize = width;
int colsize = width;
int colpercent = 100;
int leftcol = (int)(width * .25);
int rightcol = (int)(width * .75) - 4;
int imgheight = width;
bool alternate = false;

if(imageratio == "16:9"){
    imgheight = (int)(width * .56);
}else if(imageratio == "4:3"){
    imgheight = (int)(width * .75);
}

if(imageplacement =="right"){
    leftcol = (int)(width * .75) - 4;
    rightcol = (int)(width * .25);
    imgsize = leftcol - 4;
}
if(imageplacement =="left"){
    imgsize = leftcol - 4;
}

if(imageplacement =="alternate"){
    alternate=true;
    imageplacement="left";
    imgsize = leftcol - 4;
}

bool alteven = true;

if(int.TryParse(colnumber, out colno)){
    if(colno == 2){
        colsize = (int)((width/colno) - 10);
        imgsize = colsize - 4;
        colpercent = (int)(100/colno);
    }
    
    if(colno == 3){
        colsize = (int)((width/colno) - 10);
        imgsize = colsize - 4;
        colpercent = (int)(100/colno);
    }
   
}

if (!linkToDetail.StartsWith("http://") && !linkToDetail.StartsWith("https://")) {
    linkToDetail = "http://" + linkToDetail;
}
if (!linkToDetail.EndsWith("/")) {
    linkToDetail += "/";
}


@BRT.Lister(tableId:"Content", viewId:viewId, fields: new[] {"Title", "PubDate", "Body", "PrimaryImage"},ids:ids,   
template:
    @<div>
        <table border="0" cellpadding="0" cellspacing="0" class="snippetmain" style="border-collapse:separate;mso-table-lspace:0pt;mso-table-rspace:0pt;width:100%;" width="100%">
            @if(imageplacement == "left" || imageplacement == "right"){
           
                foreach(EngineRecord record in item){
                    if(alternate){
                        int lefthold = leftcol;
                        leftcol = rightcol;
                        rightcol = lefthold;
                        
                        if(alteven){
                            imageplacement = "right";
                            alteven = false;   
                            
                        }else{
                            imageplacement = "left";
                            alteven = true;
                        }
                    }
                    
                    
                    <tr>
                        <td align="center" style="vertical-align:top;" valign="top">
                              <!--[if (gte mso 9)|(IE)]>
                                <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                                <![endif]-->
                            
                                <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(imageplacement == "left"?"25":"75")%">
                                <![endif]-->
                                <div class="col-2" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(leftcol)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(leftcol)px;" width="100%">
                                       @if(imageplacement == "left"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                                        <a href="@linkToDetail@record.Href">
                                                            <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" alt="" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                        </a>    
                                                    }
                                                </td>
                                            </tr>
                                        }
                                         @if(imageplacement == "right"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                  <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b><br/>
                                                    @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                            
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                               
                               
                               <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(imageplacement == "right"?"25":"75")%">
                                <![endif]-->
                                <div class="col-2" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(rightcol)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(rightcol)px;" width="100%">
                                        @if(imageplacement == "right"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                                        <a href="@linkToDetail@record.Href">
                                                            <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" alt="" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                        </a>
                                                    }
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "left"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                  <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b><br/>
                                                  @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                               
                            
                            <!--[if (gte mso 9)|(IE)]>
                                </tr></table>
                               <![endif]-->
                           
                        </td>
                    </tr>
                }
               
            }else{
                <tr>
                    <td align="center" style="vertical-align:top;" valign="top">
                    <!--[if (gte mso 9)|(IE)]>
                    <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                    <![endif]-->
                    
                    @{
                        int lastrecno = 0;
                    }
                    
                    @foreach(EngineRecord record in item){
                    
                    if(lastrecno % colno == 0 && lastrecno > 0){
                    <!--[if (gte mso 9)|(IE)]>
                    </tr></table>
                   <![endif]-->
                        <!--close the row -->
                        @BRT.Raw("</td></tr><tr><td align=\"center\" style=\"vertical-align:top;\" valign=\"top\">")
                            <!--[if (gte mso 9)|(IE)]>
                            <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                            <![endif]-->            }
                    
                    
                    lastrecno = lastrecno + 1;
                            
                                <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(colpercent)%">
                                <![endif]-->
                                <div class="col-@(colno)" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(colsize)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(colsize)px;" width="100%">
                                        @if(imageplacement == "Top" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                        <tr>
                                            <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                              <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b>
                                              @if(imageplacement != "Middle"){
                                                <br/>@record.GetString("Body").Summarize(250)
                                              }
                                            </td>
                                        </tr>
                                        @if(imageplacement == "Middle" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "Middle"){
                                            <tr>
                                                <td style="vertical-align:top;font-size:16px;line-height:150%;" valign="top">
                                                  @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "Bottom" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                       
                        
                    }     
                
                    <!--[if (gte mso 9)|(IE)]></tr></table><![endif]-->
                    </td></tr>
                }
                </table>

        
    </div>)
    <br/>
                        
int colno = 1;
int imgsize = width;
int colsize = width;
int colpercent = 100;
int leftcol = (int)(width * .25);
int rightcol = (int)(width * .75) - 4;
int imgheight = width;
bool alternate = false;

if(imageratio == "16:9"){
    imgheight = (int)(width * .56);
}else if(imageratio == "4:3"){
    imgheight = (int)(width * .75);
}

if(imageplacement =="right"){
    leftcol = (int)(width * .75) - 4;
    rightcol = (int)(width * .25);
    imgsize = leftcol - 4;
}
if(imageplacement =="left"){
    imgsize = leftcol - 4;
}

if(imageplacement =="alternate"){
    alternate=true;
    imageplacement="left";
    imgsize = leftcol - 4;
}

bool alteven = true;

if(int.TryParse(colnumber, out colno)){
    if(colno == 2){
        colsize = (int)((width/colno) - 10);
        imgsize = colsize - 4;
        colpercent = (int)(100/colno);
    }
    
    if(colno == 3){
        colsize = (int)((width/colno) - 10);
        imgsize = colsize - 4;
        colpercent = (int)(100/colno);
    }
   
}

if (!linkToDetail.StartsWith("http://") && !linkToDetail.StartsWith("https://")) {
    linkToDetail = "http://" + linkToDetail;
}
if (!linkToDetail.EndsWith("/")) {
    linkToDetail += "/";
}


@BRT.Lister(tableId:"Content", viewId:"Events", fields: new[] {"Title", "PubDate", "Body", "PrimaryImage"},ids:ids,   
sortFields: new EngineCore.Meta.SortFieldMeta[] {new EngineCore.Meta.SortFieldMeta {FieldId = "StartDate", Descending=false}},
template:
    @<div>
        <table border="0" cellpadding="0" cellspacing="0" class="snippetmain" style="border-collapse:separate;mso-table-lspace:0pt;mso-table-rspace:0pt;width:100%;" width="100%">
            @if(imageplacement == "left" || imageplacement == "right"){
           
                foreach(EngineRecord record in item){
                    if(alternate){
                        int lefthold = leftcol;
                        leftcol = rightcol;
                        rightcol = lefthold;
                        
                        if(alteven){
                            imageplacement = "right";
                            alteven = false;   
                            
                        }else{
                            imageplacement = "left";
                            alteven = true;
                        }
                    }
                    
                    
                    <tr>
                        <td align="center" style="vertical-align:top;" valign="top">
                              <!--[if (gte mso 9)|(IE)]>
                                <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                                <![endif]-->
                            
                                <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(imageplacement == "left"?"25":"75")%">
                                <![endif]-->
                                <div class="col-2" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(leftcol)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(leftcol)px;" width="100%">
                                       @if(imageplacement == "left"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                                        <a href="@linkToDetail@record.Href">
                                                            <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" alt="" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                        </a>    
                                                    }
                                                </td>
                                            </tr>
                                        }
                                         @if(imageplacement == "right"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                  <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b><br/>
                                                    @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                            
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                               
                               
                               <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(imageplacement == "right"?"25":"75")%">
                                <![endif]-->
                                <div class="col-2" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(rightcol)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(rightcol)px;" width="100%">
                                        @if(imageplacement == "right"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                                        <a href="@linkToDetail@record.Href">
                                                            <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" alt="" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                        </a>
                                                    }
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "left"){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                  <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b><br/>
                                                  @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                               
                            
                            <!--[if (gte mso 9)|(IE)]>
                                </tr></table>
                               <![endif]-->
                           
                        </td>
                    </tr>
                }
               
            }else{
                <tr>
                    <td align="center" style="vertical-align:top;" valign="top">
                    <!--[if (gte mso 9)|(IE)]>
                    <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                    <![endif]-->
                    
                    @{
                        int lastrecno = 0;
                    }
                    
                    @foreach(EngineRecord record in item){
                    
                    if(lastrecno % colno == 0 && lastrecno > 0){
                    <!--[if (gte mso 9)|(IE)]>
                    </tr></table>
                   <![endif]-->
                        <!--close the row -->
                        @BRT.Raw("</td></tr><tr><td align=\"center\" style=\"vertical-align:top;\" valign=\"top\">")
                            <!--[if (gte mso 9)|(IE)]>
                            <table align="left" border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
                            <![endif]-->            }
                    
                    
                    lastrecno = lastrecno + 1;
                            
                                <!--[if (gte mso 9)|(IE)]>
                                <td align="left" valign="top" width="@(colpercent)%">
                                <![endif]-->
                                <div class="col-@(colno)" style="display:inline-block;margin-bottom:30px;vertical-align:top;width:100%;max-width:@(colsize)px;">
                                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; padding-left: 5px; padding-right: 5px; max-width: @(colsize)px;" width="100%">
                                        @if(imageplacement == "Top" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                        <tr>
                                            <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                              <b><a href="@linkToDetail@record.Href">@record.GetString("Title")</a></b>
                                              @if(imageplacement != "Middle"){
                                                <br/>@record.GetString("Body").Summarize(250)
                                              }
                                            </td>
                                        </tr>
                                        @if(imageplacement == "Middle" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "Middle"){
                                            <tr>
                                                <td style="vertical-align:top;font-size:16px;line-height:150%;" valign="top">
                                                  @record.GetString("Body").Summarize(250)
                                                </td>
                                            </tr>
                                        }
                                        @if(imageplacement == "Bottom" && !record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0){
                                            <tr>
                                                <td style="vertical-align:top;padding-bottom:5px;font-size:16px;line-height:150%;" valign="top">
                                                    <a href="@linkToDetail@record.Href">
                                                        <img src="http://@(CustomerContext.Current.ShortName)-email.brtapp.com@(record.GetFiles("PrimaryImage")[0].Url)?width=@(width)&height=@(imgheight)&mode=crop&enlarge=true" width="@imgsize" class="img-responsive img-block" style="border:none; -ms-interpolation-mode:bicubic;max-width:100%;display:block;" />
                                                    </a>
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                 <!--[if (gte mso 9)|(IE)]>
                                </td>
                               <![endif]-->
                       
                        
                    }     
                
                    <!--[if (gte mso 9)|(IE)]></tr></table><![endif]-->
                    </td></tr>
                }
                </table>

        
    </div>)
    <br/>
                        
@BRT.Lister(tableId:tableId,viewId:viewId,fields:fields,ids:ids,template:@<text>
    @switch(format) {
        case "Condensed":
            foreach(EngineRecord record in item) {
                <div>
                @for(int i=0;i<record.FieldCount;i++) {
                    <span>@record.get_FormattedValue(i)</span>
                }
                </div>
            }
            break;
            
        case "Detail":
            foreach(EngineRecord record in item) {
                <div>
                @for(int i=0;i<record.FieldCount;i++) {
                    <div><b>@(record.get_FieldMeta(i).Name):</b> @record.get_FormattedValue(i)</div>
                }
                    <hr/>
                </div>
            }
            break;
            
        case "Table":
            <table>
                <thead>
                    <tr>
                        @for(int i=0;i<item.FieldCount;i++) {
                            <th>@item.get_FieldMeta(i).Name</th>
                        }
                    </tr>
                </thead>
                <tbody>
                    @foreach(EngineRecord record in item) {
                    <tr>
                        @for(int i=0;i<record.FieldCount;i++) {
                            <td>@record.get_FormattedValue(i)</td>
                        }
                    </tr>
                }            
                </tbody>
            </table>
            break;
            
    }
</text>)
                        
if (!linkToDetail.StartsWith("http://") && !linkToDetail.StartsWith("https://")) {
    linkToDetail = "http://" + linkToDetail;
}
if (!linkToDetail.EndsWith("/")) {
    linkToDetail += "/";
}
@BRT.Lister(tableId:"Content", viewId:"Events",pageSize: pageSize, fields: new[] {"StartDate","Title", "PubDate", "Body", "PrimaryImage"},   
condition: new ConditionMeta.CompareCondition {FieldId = "StartDate", Op = EngineCore.Meta.ConditionOperators.LessThan, Negative=true, Value= new EngineCore.Meta.ConditionMeta.ConstantValue {Value = DateTime.Today.ToShortDateString()}},
sortFields: new EngineCore.Meta.SortFieldMeta[] {new EngineCore.Meta.SortFieldMeta {FieldId = "StartDate", Descending=false}},
itemTemplate:
@<div>
    <p>
        <b>
            <a href="@linkToDetail@item.Href">
            @if(!@item.IsDBNull("StartDate")){
                <span>@(item.GetDateTime("StartDate").ToString("MMMM"))</span>
                <span>@(item.GetDateTime("StartDate").Day.ToString("d"))</span>
                <span> - </span>
            }
            @item.GetString("Title")
            </a>
        </b>
    </p>
</div>)
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--Within the Brick River platform we use a "Helper" to generate the Event Detail page. -->
<!--This code creates that page, but also includes Related Content (Events, News, Resources and FAQs), -->
<!--therefore you must make edits to the Events View to use this code. -->
<!--The instructions are below. -->
<!--In order to work with the Events Helper, the Friendly URL of this page should be "event".-->

<!--This code block starts with default helper to load the event details, -->
<!--and is then followed by a customized lister to show related content: -->
<!--News, Events, Resources and FAQs.-->

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

<!--To use this code you MUST make the following edit to the Events View:-->

<!--In the dashboard main menu, click Admin > Views. You'll see a list of your existing views. -->
<!--If you don't see the Events view, don't worry - it exists, but you can't see it because you haven't made any edits to it yet.-->
<!--Click the green "+New" button on the right side and select "I'd like to customize an existing view". -->
<!--Select "Events (Content)" from the list.-->

<!--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">-->
<!--  <Relationship Id="RelatedEvents" TableId="Content" ViewId="Events" Name="Related Events" ShowAsTable="true" Reciprocal="true" FieldId="RelatedEvents" />-->
<!--  <Relationship Id="RelatedResources" TableId="Content" ViewId="Resources" Name="Related Resources" ShowAsTable="true" />-->
<!--  <Relationship Id="RelatedNews" TableId="Content" ViewId="News" Name="Related News" ShowAsTable="true" />-->
<!--  <Relationship Id="RelatedFAQs" TableId="Content" ViewId="FAQs" Name="Related FAQs" ShowAsTable="true" />-->
<!--</FieldSet>-->

<!--If you've previously made edits to the View, all you need to do is include the <Relationship> lines inside the "ArticleFields" fieldset.-->

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


@section head {
    <style>
        .caleventtitle {
            display: none;
        }
    </style>
}

@* --------- 
This Helper requires the use of @BRT.Calendar() on the page used to display an event calendar.
It is common to use a page called 'events' with @BRT.Calendar(DetailPage:"event") and
a page called 'event' with the Helper @BRT.CalendarDetail(returnPage:"events")
------------ *@

@BRT.CalendarDetail("events")

@BRT.Detail(tableId: "Content", viewId: "Events",
fields: new[] {"Title",
"RelatedNews.Title","RelatedNews.PrimaryImage","RelatedNews.PubDate","RelatedNews.Summary","RelatedNews.Body","RelatedNews.Topic","RelatedNews.Link",
"RelatedEvents.Title","RelatedEvents.StartDate","RelatedEvents.PrimaryImage","RelatedEvents.Summary","RelatedEvents.Body","RelatedEvents.Calendar",
"RelatedResources.Title","RelatedResources.PrimaryImage","RelatedResources.Summary","RelatedResources.Body","RelatedResources.ResourceTypes",
"RelatedFAQs.Title","RelatedFAQs.PrimaryImage","RelatedFAQs.Summary","RelatedFAQs.Body","RelatedFAQs.FAQTopics"},
template:
@<div>
    <!--RELATED EVENTS-->
    @if(!item.IsDBNull("RelatedEvents") && (item.GetRecordList("RelatedEvents").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Events</h4>
            @foreach(EngineRecord relatedevent in item.GetRecordList("RelatedEvents")) {
                <div class="media">
                    @if(!relatedevent.IsDBNull("PrimaryImage") && relatedevent.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedevent.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/event/@relatedevent.Href">
                                <img src="@(relatedevent.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedevent.GetFiles("PrimaryImage")[0].Title) ? relatedevent.GetFiles("PrimaryImage")[0].Filename : relatedevent.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/event/@relatedevent.Href">
                                @if(!relatedevent.IsDBNull("Title")) {
                                  @relatedevent["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if(!relatedevent.IsDBNull("StartDate")) {
                              <span>@relatedevent.GetDateTime("StartDate").ToString("MMMM dd, yyyy")</span>
                            }
                            @if(!relatedevent.IsDBNull("StartDate") && !relatedevent.IsDBNull("Calendar")){
                                <span> | </span>
                            }
                            @if (!relatedevent.IsDBNull("Calendar") && relatedevent.GetCategory("Calendar").Count > 0) {
                                <span class="topics">
                                    @foreach(CategoryFieldItem topic in relatedevent.GetCategory("Calendar")) {
                                        <span>@topic.Label</span>
                                    }
                                </span>
                            }
                        </small>
                        @if(!relatedevent.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedevent.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedevent.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </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">
                            <a href="/article/@item_relatednews.Href">
                                @if(!item_relatednews.IsDBNull("Title")) {
                                  @item_relatednews["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if(!item_relatednews.IsDBNull("PubDate")) {
                              <span>@item_relatednews.GetDateTime("PubDate").ToString("MMMM dd, yyyy")</span>
                            }
                            @if(!item_relatednews.IsDBNull("PubDate") && !item_relatednews.IsDBNull("Topic")){
                                <span> | </span>
                            }
                            @if (!item_relatednews.IsDBNull("Topic") && item_relatednews.GetCategory("Topic").Count > 0) {
                                <span class="topics">
                                    @foreach(CategoryFieldItem topic in item_relatednews.GetCategory("Topic")) {
                                        <span>@topic.Label</span>
                                    }
                                </span>
                            }
                        </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 RESOURCES-->
    @if(!item.IsDBNull("RelatedResources") && (item.GetRecordList("RelatedResources").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Resources</h4>
            @foreach(EngineRecord relatedResource in item.GetRecordList("RelatedResources")) {
                <article class="media">
                    @if(!relatedResource.IsDBNull("PrimaryImage") && relatedResource.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedResource.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/resource/@relatedResource.Href">
                                <img src="@(relatedResource.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedResource.GetFiles("PrimaryImage")[0].Title) ? relatedResource.GetFiles("PrimaryImage")[0].Filename : relatedResource.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/resource/@relatedResource.Href">
                                @if(!relatedResource.IsDBNull("Title")) {
                                  @relatedResource["Title"]
                                }
                            </a>
                        </h5>
                        @if (!relatedResource.IsDBNull("ResourceTypes") && relatedResource.GetCategory("ResourceTypes").Count > 0) {
                            <small class="media-metadata text-muted">
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedResource.GetCategory("ResourceTypes")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            </small>
                        }
                        @if(!relatedResource.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedResource.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedResource.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
    <!--RELATED FAQs-->
    @if(!item.IsDBNull("RelatedFAQs") && (item.GetRecordList("RelatedFAQs").Count > 0)) {
        <div class="box box-outline">
            <h4>Related FAQs</h4>
            @foreach(EngineRecord relatedFAQ in item.GetRecordList("RelatedFAQs")) {
                <article class="media">
                    @if(!relatedFAQ.IsDBNull("PrimaryImage") && relatedFAQ.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedFAQ.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/faq/@relatedFAQ.Href">
                                <img src="@(relatedFAQ.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedFAQ.GetFiles("PrimaryImage")[0].Title) ? relatedFAQ.GetFiles("PrimaryImage")[0].Filename : relatedFAQ.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/faq/@relatedFAQ.Href">
                                @if(!relatedFAQ.IsDBNull("Title")) {
                                  @relatedFAQ["Title"]
                                }
                            </a>
                        </h5>
                        @if (!relatedFAQ.IsDBNull("FAQTopics") && relatedFAQ.GetCategory("FAQTopics").Count > 0) {
                            <small class="media-metadata text-muted">
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedFAQ.GetCategory("FAQTopics")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            </small>
                        }
                        @if(!relatedFAQ.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedFAQ.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedFAQ.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
</div>)
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates an FAQ Detail page that will be used to display your FAQ articles. -->
<!--It includes the Date, Primary Image (if present), article Content (Body) and attached Files. -->
<!--In order to work with the FAQs Lister Page code block, the Friendly URL of this page should be "faq".-->

<!--This code block loads a FAQ article.-->

<!--** To use this page you must have an existing "FAQs" 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 "FAQs" 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 "FAQs" (without the quote marks) and click Create.-->

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


@BRT.Detail(tableId: "Content", viewId: "FAQs",
fields: new[] {"Title","Body","PubDate","Files","PrimaryImage"},
template:
@<div>
    <small class="media-metadata text-muted">
        @if(!item.IsDBNull("PubDate")) {
          <span>@item.GetDateTime("PubDate").ToShortDateString()</span>
        }
    </small>
    @if(!item.IsDBNull("PrimaryImage")) {
      foreach(FileFieldItem file in item.GetFiles("PrimaryImage")) {
        if(file.ContentType.StartsWith("image/")) {
            <div class="primaryImg">
                <img src="@(file.Url)?width=1050&height=300" class="img-fluid"/>
            </div>
        }
      }
    }
    @if(!item.IsDBNull("Body")) {
      <div>@BRT.Raw(@item.GetString("Body"))</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/")) {
                  <img src="@(file.Url)?width=200&height=200"/>
                } 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>)
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates an FAQ Detail page that will be used to display your FAQ articles. -->
<!--It includes the Date, Primary Image (if present), article Content (Body) and attached Files. -->
<!--The FAQs View doesn't have Topics, so you'll have to create those under Categories and update the View. -->
<!--The instructions are below. -->
<!--In order to work with the FAQs Lister Page code block, the Friendly URL of this page should be "faq".-->


<!--This code block loads a FAQ article.-->

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

<!--To use this code you MUST create the "FAQ Topics" Category and make the following edit to the "FAQs" View.-->

<!--To create the FAQTopics Category:-->

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


<!--To 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 "FAQs" 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 "FAQs" (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="FAQTopics" CatType="FAQ Topics" Name="Topics" Multiple="true" Cmd="After:Body" />-->
<!--</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.-->


@BRT.Detail(tableId: "Content", viewId: "FAQs",
fields: new[] {"Title","Body","FAQTopics","PubDate","Files"},
template:
@<div>
    <small class="media-metadata text-muted">
        @if(!item.IsDBNull("PubDate")) {
          <span>@item.GetDateTime("PubDate").ToShortDateString()</span>
        }
        @if(!item.IsDBNull("PubDate") && !item.IsDBNull("FAQTopics")){
            <span> - </span>
        }
        @if (!item.IsDBNull("FAQTopics") && item.GetCategory("FAQTopics").Count > 0) {
            <div class="topics">
                @foreach(CategoryFieldItem topic in item.GetCategory("FAQTopics")) {
                    <span>@topic.Label</span>
                }
            </div>
        }
    </small>
    @if(!item.IsDBNull("PrimaryImage")) {
      foreach(FileFieldItem file in item.GetFiles("PrimaryImage")) {
        if(file.ContentType.StartsWith("image/")) {
            <div class="primaryImg">
                <img src="@(file.Url)?width=1050&height=300" class="img-fluid"/>
            </div>
        }
      }
    }
    @if(!item.IsDBNull("Body")) {
      <div>@BRT.Raw(@item.GetString("Body"))</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/")) {
                  <img src="@(file.Url)?width=200&height=200"/>
                } 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>)
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates an FAQ Detail page that will be used to display your FAQ articles. -->
<!--It includes the Date, Primary Image (if present), article Content (Body) and attached Files. -->
<!--This code also includes Related Content ( FAQs, News, Events, Resources), -->
<!--therefore you must make edits to the FAQs View to use this code. -->
<!--The instructions are below. -->
<!--In order to work with the FAQs Lister Page code block, the Friendly URL of this page should be "faq".-->

<!--This code block loads a FAQ article, including related content (in this order): -->
<!--FAQs, News, Events, Resources.-->

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

<!--To use this code you MUST create the FAQTopics Category and make the following edit to the "FAQs" View.-->

<!--To create the FAQTopics Category:-->

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


<!--To 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 "FAQs" 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 "FAQs" (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="FAQTopics" CatType="FAQ Topics" Name="Topics" Multiple="true" Cmd="After:Body" />-->
<!--  <Relationship Id="RelatedFAQs" TableId="Content" ViewId="FAQs" Name="Related FAQs" ShowAsTable="true" Reciprocal="true" FieldId="RelatedFAQs" />-->
<!--  <Relationship Id="RelatedNews" TableId="Content" ViewId="News" Name="Related News" ShowAsTable="true" />-->
<!--  <Relationship Id="RelatedEvents" TableId="Content" ViewId="Events" Name="Related Events" ShowAsTable="true" Reciprocal="true" FieldId="RelatedFAQs" />-->
<!--  <Relationship Id="RelatedResources" TableId="Content" ViewId="Resources" Name="Related Resources" ShowAsTable="true" />-->
<!--</FieldSet>-->

<!--If you've previously made edits to the View and the "ArticleFields" fieldset is already visible, all you need to do is include the <Relationship> and <Category> lines inside the "ArticleFields" fieldset.-->

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



@BRT.Detail(tableId: "Content", viewId: "FAQs",
fields: new[] {"Title","Body","FAQTopics","PubDate","Files",
"RelatedNews.Title","RelatedNews.PrimaryImage","RelatedNews.PubDate","RelatedNews.Summary","RelatedNews.Body","RelatedNews.Topic","RelatedNews.Link",
"RelatedEvents.Title","RelatedEvents.StartDate","RelatedEvents.PrimaryImage","RelatedEvents.Summary","RelatedEvents.Body","RelatedEvents.Calendar",
"RelatedResources.Title","RelatedResources.PrimaryImage","RelatedResources.Summary","RelatedResources.Body","RelatedResources.ResourceTypes",
"RelatedFAQs.Title","RelatedFAQs.PrimaryImage","RelatedFAQs.Summary","RelatedFAQs.Body","RelatedFAQs.FAQTopics"},
template:
@<div>
    <small class="media-metadata text-muted">
        @if(!item.IsDBNull("PubDate")) {
          <span>@item.GetDateTime("PubDate").ToShortDateString()</span>
        }
        @if(!item.IsDBNull("PubDate") && !item.IsDBNull("FAQTopics")){
            <span> - </span>
        }
        @if (!item.IsDBNull("FAQTopics") && item.GetCategory("FAQTopics").Count > 0) {
            <div class="topics">
                @foreach(CategoryFieldItem topic in item.GetCategory("FAQTopics")) {
                    <span>@topic.Label</span>
                }
            </div>
        }
    </small>
    @if(!item.IsDBNull("PrimaryImage")) {
      foreach(FileFieldItem file in item.GetFiles("PrimaryImage")) {
        if(file.ContentType.StartsWith("image/")) {
            <div class="primaryImg">
                <img src="@(file.Url)?width=1050&height=300" class="img-fluid"/>
            </div>
        }
      }
    }
    @if(!item.IsDBNull("Body")) {
      <div>@BRT.Raw(@item.GetString("Body"))</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/")) {
                  <img src="@(file.Url)?width=200&height=200"/>
                } 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>
    }
    <!--RELATED FAQs-->
    @if(!item.IsDBNull("RelatedFAQs") && (item.GetRecordList("RelatedFAQs").Count > 0)) {
        <div class="box box-outline">
            <h4>Related FAQs</h4>
            @foreach(EngineRecord relatedFAQ in item.GetRecordList("RelatedFAQs")) {
                <article class="media">
                    @if(!relatedFAQ.IsDBNull("PrimaryImage") && relatedFAQ.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedFAQ.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/faq/@relatedFAQ.Href">
                                <img src="@(relatedFAQ.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedFAQ.GetFiles("PrimaryImage")[0].Title) ? relatedFAQ.GetFiles("PrimaryImage")[0].Filename : relatedFAQ.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/faq/@relatedFAQ.Href">
                                @if(!relatedFAQ.IsDBNull("Title")) {
                                  @relatedFAQ["Title"]
                                }
                            </a>
                        </h5>
                        @if (!relatedFAQ.IsDBNull("FAQTopics") && relatedFAQ.GetCategory("FAQTopics").Count > 0) {
                            <small class="media-metadata text-muted">
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedFAQ.GetCategory("FAQTopics")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            </small>
                        }
                        @if(!relatedFAQ.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedFAQ.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedFAQ.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </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">
                            <a href="/article/@item_relatednews.Href">
                                @if(!item_relatednews.IsDBNull("Title")) {
                                  @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 EVENTS-->
    @if(!item.IsDBNull("RelatedEvents") && (item.GetRecordList("RelatedEvents").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Events</h4>
            @foreach(EngineRecord relatedevent in item.GetRecordList("RelatedEvents")) {
                <div class="media">
                    @if(!relatedevent.IsDBNull("PrimaryImage") && relatedevent.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedevent.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/event/@relatedevent.Href">
                                <img src="@(relatedevent.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedevent.GetFiles("PrimaryImage")[0].Title) ? relatedevent.GetFiles("PrimaryImage")[0].Filename : relatedevent.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/event/@relatedevent.Href">
                                @if(!relatedevent.IsDBNull("Title")) {
                                  @relatedevent["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if(!relatedevent.IsDBNull("StartDate")) {
                              <span>@relatedevent.GetDateTime("StartDate").ToShortDateString()</span>
                            }
                            @if(!relatedevent.IsDBNull("StartDate") && !relatedevent.IsDBNull("Calendar")){
                                <span> | </span>
                            }
                            @if (!relatedevent.IsDBNull("Calendar") && relatedevent.GetCategory("Calendar").Count > 0) {
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedevent.GetCategory("Calendar")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            }
                        </small>
                        @if(!relatedevent.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedevent.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedevent.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </div>
            }
        </div>
    }
    <!--RELATED RESOURCES-->
    @if(!item.IsDBNull("RelatedResources") && (item.GetRecordList("RelatedResources").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Resources</h4>
            @foreach(EngineRecord relatedResource in item.GetRecordList("RelatedResources")) {
                <article class="media">
                    @if(!relatedResource.IsDBNull("PrimaryImage") && relatedResource.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedResource.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/resource/@relatedResource.Href">
                                <img src="@(relatedResource.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedResource.GetFiles("PrimaryImage")[0].Title) ? relatedResource.GetFiles("PrimaryImage")[0].Filename : relatedResource.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/resource/@relatedResource.Href">
                                @if(!relatedResource.IsDBNull("Title")) {
                                  @relatedResource["Title"]
                                }
                            </a>
                        </h5>
                        @if (!relatedResource.IsDBNull("ResourceTypes") && relatedResource.GetCategory("ResourceTypes").Count > 0) {
                            <small class="media-metadata text-muted">
                                <div class="topics">
                                    @foreach(CategoryFieldItem topic in relatedResource.GetCategory("ResourceTypes")) {
                                        <span>@topic.Label</span>
                                    }
                                </div>
                            </small>
                        }
                        @if(!relatedResource.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedResource.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedResource.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
</div>)
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a FAQs Lister containing Primary Image (if present), Date, and Summary (in the absence of Summary, -->
<!--it loads partial content of the Body). -->
<!--If you add this code to a page, it can be your "FAQs" page.-->

<!--This code block creates a FAQs lister page.-->

<!--** To use this page you must have an existing "FAQs" 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 "FAQs" 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 "FAQs" (without the quote marks) and click Create.-->

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


@BRT.Lister(tableId: "Content", viewId: "FAQs",
fields: new[] {"PrimaryImage","Title","PubDate","Summary","Body"},
condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[FAQTopics.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/")) {
                <a href="/faq/@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">
                <a href="/faq/@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>
                }
            </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>)
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a FAQs Lister containing Primary Image (if present), Date, Topic(s), -->
<!--and Summary (in the absence of Summary, it loads partial content of the Body). -->
<!--The FAQs View doesn't have Topics, so you'll have to create those under Categories and update the View. -->
<!--The instructions are below. -->
<!--If you add this code to a page, it can be your "FAQs" page.-->

<!--This code block creates a FAQs lister page with Topics.-->
<!--A column on the right side allows your visitors to filter by topic.-->

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

<!--To use this code you MUST create the "FAQTopics" Category:-->

<!--To create the FAQTopics Category:-->

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

<div class="row">
    <div class="col-sm-3 order-sm-2">
        @BRT.CategoryList(tableId:"Content", viewId:"FAQs", fieldId:"FAQTopics", 
        template: 
        @<div class="topic-list-wrap">
            <h4 class="topic-list">Topics</h4>
            <p><a href="/faqs">All</a></p>
            @foreach(EngineRecord c in item) {
                <p><a href="/faqs?topic=@c["Id"]">@c["Label"]</a></p>
            }
        </div>)
    </div>
    <div class="col-sm-9">
        @BRT.Lister(tableId: "Content", viewId: "FAQs",
        fields: new[] {"PrimaryImage","Title","PubDate","Summary","Body","FAQTopics"},
        condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[FAQTopics.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/")) {
                        <a href="/faq/@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">
                        <a href="/faq/@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("FAQTopics")){
                            <span> - </span>
                        }
                        @if (!record.IsDBNull("FAQTopics")) {
                            if(record.GetCategory("FAQTopics").Count > 1){
                                foreach(CategoryFieldItem topic in record.GetCategory("FAQTopics")) {
                                    <span class="topic">@topic.Label</span>
                                }
                            } else {
                                foreach(CategoryFieldItem topic in record.GetCategory("FAQTopics")) {
                                    <span>@topic.Label</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>)
    </div>
</div>
                        
@*---------------------here's the code------------------------

<p class="pull-right"><a href="/newsandblogsbytopic">browse by topic or author <i class="fa fa-long-arrow-right"></i></a></p>
@BRT.Index(tableId:"Content",viewId:"News",
pageSize:30,fields: new[] {"Title","PubDate","Body","Summary","Authors","PrimaryImage"}, template:
@<div>
    <div class="row">
    @{
        int recnum = 3;
    }
    @foreach(EngineRecord record in item.List) {
    
        if (recnum % 3 == 0) {
            @BRT.Raw("</div>")
            @BRT.Raw("<div class='row'>")
        }
        if(recnum<15 && item.List.PageNumber==1){
            <div class="col-sm-4">
                <div class="grid-item">
                    @if (record.GetFiles("PrimaryImage").Count==1) {
                        <div class="gridimgdiv"><a href="/postdetail/@record.Href"><img src="@record.GetFiles("PrimaryImage")[0].Url?width=263&height=175&mode=crop" /></a>
                            @if(!@record.IsDBNull("PubDate")){<div class="grid-date">@record.GetDateTime("PubDate").ToString("MMMM dd")</div>}     
                        </div>
                    }
                    else{
                        <div class="gridimgdiv"><a href="/postdetail/@record.Href"><img src="http://placehold.it/263x175" /></a>
                            @if(!@record.IsDBNull("PubDate")){<div class="grid-date">@record.GetDateTime("PubDate").ToString("MMMM dd")</div>}     
                        </div>                        
                    }
                    <h4><a href="/postdetail/@record.Href">@record["Title"]</a></h4>
                </div>
            </div>
        }
        else {            
            
            <div class="col-sm-12">
                <h4><a href="/postdetail/@record.Href">@record["Title"]</a></h4>
                @if(!@record.IsDBNull("PubDate")){
                    <div class="text-muted">@record.GetDateTime("PubDate").ToString("MMMM dd yyyy")</div>
                }
                @if(@record.IsDBNull("Summary")){
                    @BRT.Raw(record.GetString("Body").Summarize(150))
                }
                else
                {
                    @BRT.Raw(record.GetString("Summary").Summarize(150))
                }
                
                <hr/>
            </div>
            
        }
        recnum+=1;
    
    }        
    </div>
    @item.Pager
</div>)

----------------------- end of comment out *@
                        
@*
-------------------------------------------------
IF THE FIELD IS AN IMAGE AND YOU JUST WANT ONE
-------------------------------------------------
*@

@if (item.GetFiles("PrimaryImage").Count==1) {
    <a href="@item["Link"]"><img src="@item.GetFiles("PrimaryImage")[0].Url?width=231&height=129&mode=crop" />
        @item["Title"]
    </a>
}


@*
-------------------------------------------------
IF IT'S JUST A BASIC FIELD. IN THIS EXAMPLE, THERE IS A CHECK FOR THE SUMMARY FIELD AND IF IT IS NULL THEN THE BODY IS LOADED
-------------------------------------------------
*@

@if(!item.IsDBNull("Summary")){
    @item["Summary"]
}
else{
    @BRT.Raw(item.GetString("Body").Summarize(200))
}


@*
-------------------------------------------------
IF YOU ARE CHECKING RELATED VIEWS, THEN LOOPING THROUGH THEM. THIS IS A BLOG POST AND GETTING RELATED AUTHORS
-------------------------------------------------
*@

@if (!item.IsDBNull("Authors")) {

    @foreach(EngineRecord author in item.GetRecordList("Authors")) {          
        if (author.GetFiles("PrimaryImage").Count > 0) {
            <img class="img-circle" src="@author.GetFiles("PrimaryImage")[0].Url?width=50&height=50&mode=crop" />
        }
        <span>
            @if(!author.IsDBNull("FirstName")){
                <a href="/authordetail/@author.Href">@author["FirstName"] @author["LastName"]</a>
            }
        </span>
    }
}
                        
<!--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, Primary Image (if present), Body, Primary Contact information, and attached Files (if present). -->
<!--The Jobs View doesn't exist so you'll have to create it. -->
<!--The instructions are below.-->

<!--This code block loads a Job Post article.-->

<!--** 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.Detail(tableId: "Content", viewId: "JobPostings",
fields: new[] {"Title","PubDate","PrimaryImage","Body","PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files"},
template:
@<article class="detailpage">
    <div>
        <small class="text-muted">
            @if(!item.IsDBNull("PubDate")) {
                <span>@item.GetDateTime("PubDate").ToString("MMMM dd, yyyy")</span>
            }
        </small>
    </div>
    @if(!item.IsDBNull("PrimaryImage")) {
        <div class="primaryImg">
            @if(item.GetFiles("PrimaryImage").Count > 0){
                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" />
                    </figure>
                }
            } 
        </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>
</article>)
                        
<!--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 and attached Files (if present). -->
<!--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.-->

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

<!--To use this code you MUST create the "JobPostingTypes" Category and make the following edit to the "JobPostings" View.-->

<!--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.-->


<!--To 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> lines inside the "ArticleFields" fieldset.-->

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



@BRT.Detail(tableId: "Content", viewId: "JobPostings",
fields: new[] {"Title","PubDate","PrimaryImage","Body","JobPostingTypes","PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files"},
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" />
                    </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>
</article>)
                        
<!--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>
                        
<!--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>)
                        
<!--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>
                        
@if (item.GetFiles("Files").Count>0) {
    <div><b>Attached file(s)</b></div>
    for(int f=0;f < @item.GetFiles("Files").Count; f++) {
    <div><b><a href="@item.GetFiles("Files")[f].Url" target="_blank">@item.GetFiles("Files")[f].Filename</a></b></div>
    }
    
}  
OR

@if(@item.GetFiles("VideoFiles").Count > 0){
    <div><h2>Videos</h2></div>
    foreach(FileFieldItem r in item.GetFiles("VideoFiles")){
        <div class="well">
            <video width="800" height="600" controls="true">
                <source src="@r.Url" type="@r.ContentType" />
            </video>
            <h3>@r.Title</h3>
            <div>@r.Description</div>
        </div>
    }
}
                        
*******LISTER PUSH TO CHILDREN***********

options: DataHelperExtensions.DataHelperOptions.PushToChildren

******** MULTIPLE OPTIONS ***********

options: DataHelperExtensions.DataHelperOptions.PushToChildren | DataHelperExtensions.DataHelperOptions.ShowInvisible,
                        
@section head {
}

@functions{ 


    EngineRecordList getFormVites(){
    
    EngineAdapter ad = EngineAdapter.Create("FormVites", "FormVites"); 
    ad.AddResultFields(new[] {"RegForms", "RegFormsOptional", "RegFormsMulti","DocumentType"});
    ad.AddCondition("<Eq FieldId=\"AddToEbridge\" Value=\"true\"/>");
    
        return ad.GetList(1, 1000);
    }


    System.Collections.Generic.List<Int32> AllFormIds(EngineRecordList formViteForms){
    
        System.Collections.Generic.List<Int32> _eventIds = new System.Collections.Generic.List<Int32>();
        
        foreach(EngineRecord fv in formViteForms){
             if(formViteForms.Count > 0){
                foreach(EngineRecord i in formViteForms){
                    if(i.GetRecordList("RegForms").Count > 0){
                        foreach(EngineRecord r in i.GetRecordList("RegForms")){
                            if(!_eventIds.Contains(r.Id.Value)){
                                _eventIds.Add(r.Id.Value);
                            }
                        }
                    }
                    
                    if(i.GetRecordList("RegFormsOptional").Count > 0){
                        foreach(EngineRecord r in i.GetRecordList("RegFormsOptional")){
                            if(!_eventIds.Contains(r.Id.Value)){
                                _eventIds.Add(r.Id.Value);
                            }
                        }
                    }
                    
                    if(i.GetRecordList("RegFormsMulti").Count > 0){
                        foreach(EngineRecord r in i.GetRecordList("RegFormsMulti")){
                            if(!_eventIds.Contains(r.Id.Value)){
                                _eventIds.Add(r.Id.Value);
                            }
                        }
                    }
                }
             }
        }
        
        return _eventIds;
    
    }
     // END ATTACHMENT STUFF

        EngineRecordList getLinks(int fvId, string lastRunDate, EngineRecordList formViteForms){

    System.Collections.Generic.List<Int32> _eventIds = new System.Collections.Generic.List<Int32>();
    string eventIdCondition = "";
    //Get RegFormIds For the FormVites
    
     if(formViteForms.Count > 0){
    
        foreach(EngineRecord i in formViteForms){
            if(i.Id == fvId){
                if(i.GetRecordList("RegForms").Count > 0){
                    foreach(EngineRecord r in i.GetRecordList("RegForms")){
                        if(!_eventIds.Contains(r.Id.Value)){
                            _eventIds.Add(r.Id.Value);
                            eventIdCondition += "<Match Value=\"" + r.Id.Value.ToString()  + "\"/>";
                        }
                    }
                }
            
                if(i.GetRecordList("RegFormsOptional").Count > 0){
                    foreach(EngineRecord r in i.GetRecordList("RegFormsOptional")){
                        if(!_eventIds.Contains(r.Id.Value)){
                            _eventIds.Add(r.Id.Value);
                            eventIdCondition += "<Match Value=\"" + r.Id.Value.ToString()  + "\"/>";
                        }
                    }
                }
            
                if(i.GetRecordList("RegFormsMulti").Count > 0){
                    foreach(EngineRecord r in i.GetRecordList("RegFormsMulti")){
                        if(!_eventIds.Contains(r.Id.Value)){
                            _eventIds.Add(r.Id.Value);
                            eventIdCondition += "<Match Value=\"" + r.Id.Value.ToString()  + "\"/>";
                        }
                    }
                }
            
             }
        }
     }

    string contactIdCondition = "";
   
    //Get Latest Approved Formvites 
    EngineAdapter ad = EngineAdapter.Create("FormInvitees"); 
    ad.AddResultFields(new[] {"ContactId" });
    ad.AddCondition("<Eq FieldId=\"FormVitesId\" Value=\"" + fvId.ToString() + "\"/>");
    ad.AddCondition("<Ge Not=\"false\" FieldId=\"SubmittedDate\" Value=\"" + lastRunDate + "\"/>");
    EngineRecordList invitees = ad.GetList(1, 2000);
      
     
     EngineRecordList churches = null;
        
     if(invitees.Count > 0){
    
        foreach(EngineRecord i in invitees){
            contactIdCondition += "<Match Value=\"" + @i.GetInteger("ContactId").ToString()  + "\"/>";
        }
      //Get church records and reg forms
        EngineAdapter ad3 = EngineAdapter.Create("Contacts","Churches"); 
        
        ad3.AddResultFields(new[] {"FirstName","District.Name","Registrations.AccessKey","Registrations.RegisterDate","Registrations.EventId","Registrations.EventName","Registrations.WhenUpdated","GCFANumber"});
        ad3.AddCondition("<And><InList FieldId=\"Id\">" + contactIdCondition + "</InList><InList FieldId=\"Registrations.EventId\">" + eventIdCondition + "</InList></And>", true);
        churches = ad3.GetList(1, 2000);  
        
     }
      
   return churches;
    
    //End getLinks    
    } 
 
 //End Functions
}  


@{
    string lastRunDate = "";
    string thisRunDate = "";
}

@if(!String.IsNullOrEmpty(Request.QueryString["lrd"])){
    
    lastRunDate = Request.QueryString["lrd"];
    thisRunDate = DateTime.Now.ToString("G");
   
    <div>
    @("lrd" + @thisRunDate)
    </div>

 

   EngineRecordList FormVites = getFormVites();
     
     System.Collections.Generic.List<Int32> FormViteIds = new System.Collections.Generic.List<Int32>();
     
     foreach(EngineRecord fv in FormVites){
        FormViteIds.Add(fv.Id.Value);
     }
     
     System.Collections.Generic.List<Int32> FormIds = AllFormIds(FormVites);
     System.Collections.Generic.List<Int32> fakeIds = new System.Collections.Generic.List<Int32>(){1};
     System.Collections.Generic.List<Int32> FormsWithFiles = new System.Collections.Generic.List<Int32>();
     

     
     foreach(int f in FormIds){
        @BRT.RegData(f, pageSize:1,regIds:fakeIds,
        template:
        @<text>
            @foreach(RegDataHelperExtensions.EventRegData.Question q in item.Questions){
                if(q.Type == 12){
                    FormsWithFiles.Add(f);
                }
            }
        </text>);
     }
    
    foreach(EngineRecord fv in FormVites){
     int fvId = fv.Id.Value;
     string fvDocumentType = "None";
     if(!fv.IsDBNull("DocumentType")){
        fvDocumentType = fv.GetFirstCategoryLabel("DocumentType");
     }
    
       EngineRecordList churches = getLinks(fvId,lastRunDate,FormVites );
        
        if(churches != null){
            foreach(EngineRecord church in churches){
                if(church.GetRecordList("Registrations").Count > 0){
                    foreach(EngineRecord reg in church.GetRecordList("Registrations")){
                        <div>
                        *|https://iaumc-reg.brtapp.com/confirmcondensed/@reg.GetString("AccessKey")|@(church.GetString("FirstName").Replace("\\","").Replace("/","").Replace(" ","").Replace(",","").Replace("(","").Replace(")","") + "-" +  @reg.Id.Value.ToString() +  ".pdf")|@(church.GetRecordList("District").Count > 0? church.GetRecordList("District")[0].GetString("Name"):"")|@church.GetString("FirstName") - @(church.GetString("GCFANumber") + "CH")|@reg.GetDateTime("WhenUpdated").ToString("MM/dd/yyyy")|@(reg.GetString("EventName") + " _FV_|" + fvDocumentType)
                        </div>
                        
                        if(FormsWithFiles.Contains(reg.GetInteger("EventId"))){
                            @BRT.RegData(reg.GetInteger("EventId"), pageSize:1,accessKeys:new System.Collections.Generic.List<string>(){reg.GetString("AccessKey")},
                            template:
                            @<text>
                                @foreach(RegDataHelperExtensions.EventRegData.Registration regg  in item.Registrations){
                                    foreach(RegDataHelperExtensions.EventRegData.Registrant registrant in regg.Registrants){
                                        foreach(RegDataHelperExtensions.EventRegData.RegistrantAnswer a in registrant.Answers){
                                            if(a.AnswerFiles.Count > 0){
                                                foreach(String surl in a.AnswerFiles){
                                                    <div>
                                                        @{
                                                        string newname = @reg.Id.Value.ToString() + "-" + System.IO.Path.GetFileNameWithoutExtension(surl) + ".pdf";
                                                        string oldname = @reg.Id.Value.ToString() + "-" + System.IO.Path.GetFileName(surl);
                                                        }
                                                        @(System.IO.Path.GetExtension(surl).Trim() == ".pdf"?"==":"+++")|@surl|@newname|@(church.GetRecordList("District").Count > 0? church.GetRecordList("District")[0].GetString("Name"):"")|@church.GetString("FirstName") - @(church.GetString("GCFANumber") + "CH")|@reg.GetDateTime("WhenUpdated").ToString("MM/dd/yyyy")|@(reg.GetString("EventName") + " _FV_") |@oldname|@fvDocumentType
                                                    </div>
                                                }
                                            }
                                               
                                        }
                                        
                                    }
                                }
                            </text>)
        
        
                        }
                    }
                }
            }
        }

    }
    

}
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a News Article Detail page that will be used to display each News Articles. -->
<!--It includes Date, Topic(s), Primary Image, Body, Contact Information, attached Files and Author(s).-->
<!--In order to work with the News Lister Page code block, the Friendly URL of this page should be "article".-->

<!--This code block creates a News article page including topics.-->
<!--The code detects the presence of Primary Images, and if there is more than one, it'll automatically create a carousel.-->

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

<!--To use this code you MUST do the following:-->

<!--In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > slick-->
    
<!--    Download the following files and upload them to the "slick" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/ajax-loader.gif-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick-carousel.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.min.js-->

@section head{
    <link href="/files/content/www/slick/slick.css" rel="stylesheet"/>
    <link href="/files/content/www/slick/slick-carousel.css" rel="stylesheet"/>
}

@BRT.Detail(tableId: "Content", viewId: "News",
fields: new[] {"Title","PubDate","PrimaryImage","Body","Topic","PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files",
"Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
"Authors.NameSuffix","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link"},
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("Topic")) && item.GetCategory("Topic").Count > 0) {
                <span> - </span>
            }
            @if (!item.IsDBNull("Topic") && item.GetCategory("Topic").Count > 0) {
                <span class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("Topic")) {
                        <span>@topic.Label</span>
                    }
                </span>
            }
        </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" />
                    </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>
        }
        @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
            string authorCount = "Authors";
            if(item.GetRecordList("Authors").Count == 1) {
                authorCount = "Author";
            }
            <div class="box box-bg">
                <h4>@authorCount</h4>
                @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <div class="media">
                        @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                            if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                                <a href="/author/@item_authors.Href">
                                    <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                        <div class="media-body">
                            <h5>
                                <a href="/author/@item_authors.Href">
                                    @if(!item_authors.IsDBNull("PreferredName")) {
                                        <span>@item_authors["PreferredName"]</span>
                                    } else {
                                        <span>@item_authors["FirstName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("MiddleName")) {
                                        <span>@item_authors["MiddleName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("LastName")) {
                                        <span>@item_authors["LastName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("NameSuffix")) {
                                        <span>@item_authors["NameSuffix"]</span>
                                    }
                                </a>
                            </h5>
                            @if(!item_authors.IsDBNull("Description")) {
                                <p>@item_authors.GetString("Description").Summarize(250)</p>
                            }
                            <div class="social">
                                @if(!item_authors.IsDBNull("Email")) {
                                    <span><a href="mailto:@item_authors["Email"]" class="email"></a></span>
                                }
                                @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                    foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                        if(!item_authors_links.IsDBNull("Type")) {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                    data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                                ></a></span>
                                            }
                                        } else {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                    data-toggle="tooltip" title="Link" 
                                                ></a></span>
                                            }
                                        }
                                    }
                                }
                            </div>
                        </div>
                    </div>
                }
            </div>
        }
    </div>
</article>)

<script src="/files/content/www/slick/slick.min.js"></script>
<script>
    // initialize carousel
    $('.in-page-carousel').slick({
        slidesToShow: 1
        , autoplay: false
        , dots: false
    });
    $(".slick-prev, .slick-next").text("");

</script>
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a News Article Detail page that will be used to display each News Articles. -->
<!--It includes Date, Topic(s), Primary Image, Body, Contact Information, attached Files and Author(s). -->
<!--It also includes Related Content (News, Events, Resources, Photo Albums), -->
<!--therefore you must make edits to the News View to use this code. -->
<!--The instructions are below.-->
<!--In order to work with the News Lister Page code block, the Friendly URL of this page should be "article".-->

<!--This code block creates a detail News article page including topic and related content: -->
<!--News, Events, Resources and Photo Albums.-->
<!--The code detects the presence of Primary Images, and if there is more than one, it'll automatically create a carousel.-->

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

<!--To use this code you MUST do the following:-->

<!--1 - Make the edit below to the "News" View:-->

<!--    In the dashboard main menu, click Admin > Views. You'll see a list of your existing views. -->
<!--    If you don't see the "News" view, don't worry - it exists, but you can't see it because you haven't made any edits to it yet.-->
<!--    Click the green "+New" button on the right side and select "I'd like to customize an existing view". -->
<!--    Select "News (Content)" from the list.-->
    
<!--    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">-->
<!--      <Relationship Id="RelatedNews" Name="Related News Articles" TableId="Content" ViewId="News" ShowAsTable="true" />-->
<!--      <Relationship Id="RelatedEvents" Name="Related Events" TableId="Content" ViewId="Events" ShowAsTable="true" />-->
<!--      <Relationship Id="RelatedResources" Name="Related Resources" TableId="Content" ViewId="Resources" 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> lines inside the "ArticleFields" fieldset.-->
    
<!--    Save the view.-->


<!--2 - In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > slick-->
    
<!--    Download the following files and upload them to the "slick" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/ajax-loader.gif-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick-carousel.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.min.js-->
@section head{
    <link href="/files/content/www/slick/slick.css" rel="stylesheet"/>
    <link href="/files/content/www/slick/slick-carousel.css" rel="stylesheet"/>
}

@BRT.Detail(tableId: "Content", viewId: "News",
fields: new[] {"Title","PubDate","PrimaryImage","Body","Topic","PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files",
"RelatedNews.Title","RelatedNews.PrimaryImage","RelatedNews.PubDate","RelatedNews.Summary","RelatedNews.Body","RelatedNews.Topic","RelatedNews.Link",
"RelatedEvents.Title","RelatedEvents.StartDate","RelatedEvents.PrimaryImage","RelatedEvents.Summary","RelatedEvents.Body","RelatedEvents.Calendar",
"RelatedResources.Title","RelatedResources.PrimaryImage","RelatedResources.Summary","RelatedResources.Body","RelatedResources.ResourceTypes",
"RelatedAlbums.Title","RelatedAlbums.PrimaryImage","RelatedAlbums.Summary","RelatedAlbums.Body","RelatedAlbums.PhotoAlbumTopics",
"Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
"Authors.NameSuffix","Authors.DoNotEmail","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link"},
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("Topic")) && item.GetCategory("Topic").Count > 0) {
                <span> - </span>
            }
            @if (!item.IsDBNull("Topic") && item.GetCategory("Topic").Count > 0) {
                <div class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("Topic")) {
                        <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" />
                    </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>
        }
        @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
            string authorCount = "Authors";
            if(item.GetRecordList("Authors").Count == 1) {
                authorCount = "Author";
            }
            <div class="box box-bg">
                <h4>@authorCount</h4>
                @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <div class="media">
                        @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                            if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                                <a href="author/@item_authors.Href">
                                    <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                        <div class="media-body">
                            <h5>
                                <a href="/author/@item_authors.Href">
                                    @if(!item_authors.IsDBNull("PreferredName")) {
                                        <span>@item_authors["PreferredName"]</span>
                                    } else {
                                        <span>@item_authors["FirstName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("MiddleName")) {
                                        <span>@item_authors["MiddleName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("LastName")) {
                                        <span>@item_authors["LastName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("NameSuffix")) {
                                        <span>@item_authors["NameSuffix"]</span>
                                    }
                                </a>
                            </h5>
                            @if(!item_authors.IsDBNull("Description")) {
                                <p>@item_authors.GetString("Description").Summarize(250)</p>
                            }
                            <div class="social">
                                @if(!item_authors.IsDBNull("Email")) {
                                    <span><a href="mailto:@item_authors["Email"]" class="email"></a></span>
                                }
                                @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                    foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                        if(!item_authors_links.IsDBNull("Type")) {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                    data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                                ></a></span>
                                            }
                                        } else {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                    data-toggle="tooltip" title="Link" 
                                                ></a></span>
                                            }
                                        }
                                    }
                                }
                            </div>
                        </div>
                    </div>
                }
            </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")) {
                                foreach(CategoryFieldItem topic in item_relatednews.GetCategory("Topic")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </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 EVENTS-->
    @if(!item.IsDBNull("RelatedEvents") && (item.GetRecordList("RelatedEvents").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Events</h4>
            @foreach(EngineRecord relatedevent in item.GetRecordList("RelatedEvents")) {
                <article class="media">
                    @if(!relatedevent.IsDBNull("PrimaryImage") && relatedevent.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedevent.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/event/@relatedevent.Href">
                                <img src="@(relatedevent.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedevent.GetFiles("PrimaryImage")[0].Title) ? relatedevent.GetFiles("PrimaryImage")[0].Filename : relatedevent.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/event/@relatedevent.Href">
                                @if(!relatedevent.IsDBNull("Title")) {
                                  @relatedevent["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if(!relatedevent.IsDBNull("StartDate")) {
                              <span>@relatedevent.GetDateTime("StartDate").ToShortDateString()</span>
                            }
                            @if(!relatedevent.IsDBNull("StartDate") && !relatedevent.IsDBNull("Calendar")){
                                <span> | </span>
                            }
                            @if (!relatedevent.IsDBNull("Calendar")) {
                                foreach(CategoryFieldItem topic in relatedevent.GetCategory("Calendar")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </small>
                        @if(!relatedevent.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedevent.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedevent.GetString("Body").Summarize(250))</p>
                        }
                    </div>   
                </article>
            }
        </div>
    }
    <!--RELATED RESOURCES-->
    @if(!item.IsDBNull("RelatedResources") && (item.GetRecordList("RelatedResources").Count > 0)) {
        <div class="box box-outline">
            <h4>Related Resources</h4>
            @foreach(EngineRecord relatedResource in item.GetRecordList("RelatedResources")) {
                <article class="media">
                    @if(!relatedResource.IsDBNull("PrimaryImage") && relatedResource.GetFiles("PrimaryImage").Count > 0) {
                        if(relatedResource.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                            <a href="/resource/@relatedResource.Href">
                                <img src="@(relatedResource.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="mr-3 img-fluid" alt="@(String.IsNullOrEmpty(relatedResource.GetFiles("PrimaryImage")[0].Title) ? relatedResource.GetFiles("PrimaryImage")[0].Filename : relatedResource.GetFiles("PrimaryImage")[0].Title)"/>
                            </a>
                        }
                    }
                    <div class="media-body">
                        <h5 class="mt-0">
                            <a href="/resource/@relatedResource.Href">
                                @if(!relatedResource.IsDBNull("Title")) {
                                  @relatedResource["Title"]
                                }
                            </a>
                        </h5>
                        <small class="media-metadata text-muted">
                            @if (!relatedResource.IsDBNull("ResourceTypes")) {
                                foreach(CategoryFieldItem topic in relatedResource.GetCategory("ResourceTypes")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </small>
                        @if(!relatedResource.IsDBNull("Summary")) {
                            <p>@BRT.Raw(@relatedResource.GetString("Summary").Summarize(250))</p>
                        } else {
                            <p>@BRT.Raw(@relatedResource.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("PhotoAlbumTopics")) {
                                foreach(CategoryFieldItem topic in relatedAlbum.GetCategory("PhotoAlbumTopics")) {
                                    <span>@topic.Label</span>
                                }
                            }
                        </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 src="/files/content/www/slick/slick.min.js"></script>
<script>
    // initialize carousel
    $('.in-page-carousel').slick({
        slidesToShow: 1
        , autoplay: false
        , dots: false
    });
    $(".slick-prev, .slick-next").text("");

</script>
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a News Lister containing Date, Topic(s), Primary Image (if present), -->
<!--and Summary (in the absence of Summary, it loads partial content of the Body). -->
<!--If you add this code to a page, it can be your "News" page.-->

<!--This code block creates a "News" lister page with Topics.-->
<!--A column on the right side allows your visitors to filter by topic.-->


<div class="row">
    <div class="col-sm-4 order-sm-2">
        @BRT.CategoryList(tableId:"Content", viewId:"News", fieldId:"Topic", 
        template: 
        @<div class="topic-list-wrap">
            <h4 class="topic-list">Filter by Topic</h4>
            <p><a href="/news">All</a></p>
            @foreach(EngineRecord c in item) {
                <p><a href="/news?topic=@c["Id"]">@c["Label"]</a></p>
            }
        </div>)
    </div>
    @BRT.Lister(tableId: "Content", viewId: "News",
    fields: new[] {"Title","PubDate","PrimaryImage","Summary","Body","Topic","Link"},
    condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[Topic.Id]='" + Request.QueryString["topic"] + "'")),
    template:
    @<div class="lister">
        @foreach(EngineRecord record in item) {
            string newwindow = null; 
            string link = null;
            if(!record.IsDBNull("Link")){
                link = record.GetString("Link");
                newwindow=" target=\"_blank\" ";
            }  else {
                link = "/article/" + record.Href;
            }
            <article class="media">
                @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0) {
                    if(record.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                        <a href="@link" @newwindow>
                            <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="@link" @newwindow>
                            @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("Topic")){
                            <span> - </span>
                        }
                        @if (!record.IsDBNull("Topic")) {
                            if(record.GetCategory("Topic").Count > 1){
                                foreach(CategoryFieldItem topic in record.GetCategory("Topic")) {
                                    <span class="topic">@topic.Label</span>
                                }
                            } else {
                                foreach(CategoryFieldItem topic in record.GetCategory("Topic")) {
                                    <span>@topic.Label</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>)
</div>
                        
@*
Put this in the <head>

<link href="/files/content/www/assets/owl.carouselfull.css" rel="stylesheet">

Need to also have jQuery and then call the Owl js file
<script type="text/javascript" src="/files/content/www/assets/owl.carousel.js"></script>

Below is the code that calls features that are set in a certain area.
Change up the value for the Area.Id

You can download the files from here:

http://brt-email.brtapp.com/files/central_assets/forcodesnippets/owl.carousel.min.js
http://brt-email.brtapp.com/files/central_assets/forcodesnippets/owl.carouselfull.css

*@

<!--============================-->
<!--CAROUSEL START-->
<!--============================-->
<div id="carousel-wrap">
    @BRT.Lister(tableId:"Content",viewId:"Features",fields: new[] {"Title","PrimaryImage", "Summary", "Link"}, savedFilters:new[] {"Visible"}, 
    condition: "<Eq FieldId=\"Area.Id\" Value=\"23498\"/>",
    template:
    @<text>
    <div id="home-carousel"  class="owl-carousel">
        @{ int i = 1; }
        @foreach(EngineRecord record in item) {
        <div class="copy-box-wrap">
            <a href="@record.GetString("Link")"><img src="@record.GetFiles("PrimaryImage")[0].Url?width=570&height=420&mode=crop" alt="" /></a>
            <div class="copy-box">
                <h3><a href="@record.GetString("Link")">@record.GetString("Title")</a></h3>
                @if (!record.IsDBNull("Summary")) {
                    <p class="hidden-xs">@record.GetString("Summary").Summarize(190)</p>
                } 
            </div>
            <div class="caro-count">
                @i
            </div>
        </div>
        i++;
        }
        
    </div>
    <div class="caro-total-count"><span id="startcaro">1</span> to <span id="endcaro">3</span> of @item.Count</div>    
    </text>)
    
</div>
<!--============================-->
<!--CAROUSEL END-->
<!--============================-->
                        
@if(Request.QueryString["p"]!="thepassword" &&  !BRT.RenderContext.IsDesign)
{
    <form method="get">
        Enter the page password <input type="text" name="p"/> <input type="submit" value="submit"/>
    </form>
    return;
}

<div>text here</div>
                        
@*-------------creating a PageData[""] variable. Imagine I'm in the layout-----------------*@
PageData["Name"] =  "";

@*-------------creating a PageData[""] variable. Imagine I'm in the page passing the variable up to the layout -----------------*@
@functions{
    public override void InitializePage() {    
        PageData["Name"] = 161;
        base.InitializePage();
    }
}

*@
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Photo Album Detail page that will be used to display each Photo Album. -->
<!--It'll display the photos in the album, and then the Author(s)' information. -->
<!--The Photo Albums view doesn't exist, so you'll have to create it. -->
<!--The instructions are included in the beginning of the code as comments. -->
<!--In order to work with the Photo Albums Lister Page code block, the Friendly URL of this page should be "album".-->

<!--This code block creates a detail Photo Album page including author(s) info (if present).-->

<!--** To use this page you must have an existing "Photo Albums" 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 "PhotoAlbums" 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 "Photo Albums" (without the quote marks) and click Create.-->

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

<!--* All "Detail" pages should be marked "Hide from menus" and "Hide in sitemap" in the page's Properties tab.-->


@section head {
    <link href="/files/content/www/lightbox/lightbox.css" rel="stylesheet"/>
    <link href="/files/content/www/lightbox/photoalbums.css" rel="stylesheet"/>
}


<div id="photogalleries">
    @BRT.Detail(tableId: "Content", viewId: "PhotoAlbums",
    fields: new[] {"Title","Files","Authors","Body",
    "Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
    "Authors.NameSuffix","Authors.DoNotEmail","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link"},
    template:
    @<div class="album">
        <small>
            <div class="media-metadata text-muted">
                @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
                  <span>by: </span>
                  <span class="topics">
                      @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                        <span>
                            <a href="/author/@item_authors.Href">
                                @if(!item_authors.IsDBNull("PreferredName")) {
                                    <span>@item_authors["PreferredName"]</span>
                                } else {
                                    <span>@item_authors["FirstName"]</span>
                                }
                                @if(!item_authors.IsDBNull("MiddleName")) {
                                    <span>@item_authors["MiddleName"]</span>
                                }
                                @if(!item_authors.IsDBNull("LastName")) {
                                    <span>@item_authors["LastName"]</span>
                                }
                                @if(!item_authors.IsDBNull("NameSuffix")) {
                                    <span>@item_authors["NameSuffix"]</span>
                                }
                            </a>
                        </span>
                        }
                  </span>
                }
            </div>
        </small>
        @if(!item.IsDBNull("Body")){
            <div>@BRT.Raw(@item.GetString("Body"))</div>
        }
        <div class="row">
            @if (item.GetFiles("Files").Count>0) {
                for(int photo = 0; photo < @item.GetFiles("Files").Count; photo++) {
                    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                        <div class="albumbox">
                            <a href="@item.GetFiles("Files")[photo].Url" data-title="@item.GetFiles("Files")[photo].Description" data-lightbox="gallery"><img class="img-fluid" src="@item.GetFiles("Files")[photo].Url?width=468&height=468&mode=crop&enlarge=true" /></a>
                                @if(!String.IsNullOrEmpty(item.GetFiles("Files")[photo].Title) || !String.IsNullOrEmpty(item.GetFiles("Files")[photo].Description)){
                                    <a href="@item.GetFiles("Files")[photo].Url" data-title="@item.GetFiles("Files")[photo].Description" data-lightbox="gallery">
                                        <div class="albumdeets">
                                            <h5 class="albumtitle">@item.GetFiles("Files")[photo].Title</h5>
                                        </div>
                                    </a>
                                }
                        </div>
                    </div>
                }
            }
        </div>
        @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
            string authorCount = "Authors";
            if(item.GetRecordList("Authors").Count == 1) {
                authorCount = "Author";
            }
            <div class="box box-bg">
                <h4>@authorCount</h4>
                @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <div class="media">
                        @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                            if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                                <a href="/author/@item_authors.Href">
                                    <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                        <div class="media-body">
                            <h5>
                                <a href="/author/@item_authors.Href">
                                    @if(!item_authors.IsDBNull("PreferredName")) {
                                        <span>@item_authors["PreferredName"]</span>
                                    } else {
                                        <span>@item_authors["FirstName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("MiddleName")) {
                                        <span>@item_authors["MiddleName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("LastName")) {
                                        <span>@item_authors["LastName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("NameSuffix")) {
                                        <span>@item_authors["NameSuffix"]</span>
                                    }
                                </a>
                            </h5>
                            @if(!item_authors.IsDBNull("Description")) {
                                <p>@item_authors.GetString("Description").Summarize(250)</p>
                            }
                            <div class="social">
                                @if(!item_authors.IsDBNull("Email")) {
                                    <span><a href="mailto:@item_authors["Email"]" class="email"
                                        data-toggle="tooltip" title="Email"
                                    ></a></span>
                                }
                                @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                    foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                        if(!item_authors_links.IsDBNull("Type")) {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                    data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                                ></a></span>
                                            }
                                        } else {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                    data-toggle="tooltip" title="Link" 
                                                ></a></span>
                                            }
                                        }
                                    }
                                }
                            </div>
                        </div>
                    </div>
                }
            </div>
        }
    </div>)
</div>

<script src="/files/content/www/lightbox/lightbox.min.js"></script>
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Photo Album Detail page that will be used to display each Photo Album. -->
<!--It'll display the photos in the album, and then the Author(s)' information. -->
<!--The Photo Albums View and Category don't exist, so you'll have to create them. -->
<!--The instructions are below. -->
<!--In order to work with the Photo Albums Lister Page code block, the Friendly URL of this page should be "album".-->

<!--This code block creates a detail Photo Album page including author(s) info (if present) and topic.-->

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

<!--To use this code you MUST do the following:-->

<!--1- create the "Photo Album Topics" Category:-->

<!--    In the dashboard main menu, click Admin > Categories. Click the green "+New Category Type" button on the right, and name it "Photo Album Topics".-->
<!--    Click save. You may now create the topics for your Photo Albums.-->
<!--    Save your edits.-->

<!--2 - In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > lightbox-->
    
<!--    Download the following files and upload them to the "lightbox" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/lightbox.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/photoalbum.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/lightbox.min.js-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/close.png-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/loading.gif-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/next.png-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/prev.png-->
    
<!--3 - Edit the Photo Albums View:-->

<!--In the dashboard main menu, click Admin > Views. You'll see a list of your existing views. -->
<!--If you don't see the "PhotoAlbums" 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 "Photo Albums" (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="PhotoAlbumTopics" CatType="Photo Album Topics" Multiple="true" Name="Album Topics" />-->
<!--</FieldSet>-->

<!--If you've previously made edits to the View and the "ArticleFields" fieldset is already visible, all you need to do is include the <Category> lines inside the "ArticleFields" fieldset.-->

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


@section head {
    <link href="/files/content/www/lightbox/lightbox.css" rel="stylesheet"/>
    <link href="/files/content/www/lightbox/photoalbums.css" rel="stylesheet"/>
}


<div id="photogalleries">
    @BRT.Detail(tableId: "Content", viewId: "PhotoAlbums",
    fields: new[] {"Title","Files","Authors","Body","PhotoAlbumTopics",
    "Authors.PrimaryImage","Authors.Type","Authors.PreferredName","Authors.FirstName","Authors.MiddleName","Authors.LastName",
    "Authors.NameSuffix","Authors.DoNotEmail","Authors.Email","Authors.Description","Authors.Links.Type","Authors.Links.Link"},
    template:
    @<div class="album">
        <small>
            <div class="media-metadata text-muted">
                @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
                  <span>by: </span>
                  <span class="topics">
                      @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                        <span>
                            <a href="/author/@item_authors.Href">
                                @if(!item_authors.IsDBNull("PreferredName")) {
                                    <span>@item_authors["PreferredName"]</span>
                                } else {
                                    <span>@item_authors["FirstName"]</span>
                                }
                                @if(!item_authors.IsDBNull("MiddleName")) {
                                    <span>@item_authors["MiddleName"]</span>
                                }
                                @if(!item_authors.IsDBNull("LastName")) {
                                    <span>@item_authors["LastName"]</span>
                                }
                                @if(!item_authors.IsDBNull("NameSuffix")) {
                                    <span>@item_authors["NameSuffix"]</span>
                                }
                            </a>
                        </span>
                        }
                  </span>
                }
                @if((!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) && (!item.IsDBNull("PhotoAlbumTopics") && item.GetCategory("PhotoAlbumTopics").Count > 0)){
                    <span> - </span>
                }
                @if (!item.IsDBNull("PhotoAlbumTopics") && item.GetCategory("PhotoAlbumTopics").Count > 0) {
                    <span class="topics">
                        @foreach(CategoryFieldItem topic in item.GetCategory("PhotoAlbumTopics")) {
                            <span>@topic.Label</span>
                        }
                    </span>
                }
            </div>
        </small>
        @if(!item.IsDBNull("Body")){
            <div>@BRT.Raw(@item.GetString("Body"))</div>
        }
        <div class="row">
            @if (item.GetFiles("Files").Count>0) {
                for(int photo = 0; photo < @item.GetFiles("Files").Count; photo++) {
                    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                        <div class="albumbox">
                            <a href="@item.GetFiles("Files")[photo].Url" data-title="@item.GetFiles("Files")[photo].Description" data-lightbox="gallery"><img class="img-fluid" src="@item.GetFiles("Files")[photo].Url?width=468&height=468&mode=crop&enlarge=true" /></a>
                                @if(!String.IsNullOrEmpty(item.GetFiles("Files")[photo].Title) || !String.IsNullOrEmpty(item.GetFiles("Files")[photo].Description)){
                                    <a href="@item.GetFiles("Files")[photo].Url" data-title="@item.GetFiles("Files")[photo].Description" data-lightbox="gallery">
                                        <div class="albumdeets">
                                            <h5 class="albumtitle">@item.GetFiles("Files")[photo].Title</h5>
                                        </div>
                                    </a>
                                }
                        </div>
                    </div>
                }
            }
        </div>
        @if(!item.IsDBNull("Authors") && item.GetRecordList("Authors").Count > 0) {
            string authorCount = "Authors";
            if(item.GetRecordList("Authors").Count == 1) {
                authorCount = "Author";
            }
            <div class="box box-bg">
                <h4>@authorCount</h4>
                @foreach(EngineRecord item_authors in item.GetRecordList("Authors")) {
                    <div class="media">
                        @if(!item_authors.IsDBNull("PrimaryImage") && item_authors.GetFiles("PrimaryImage").Count > 0) {
                            if(item_authors.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                                <a href="/author/@item_authors.Href">
                                    <img src="@(item_authors.GetFiles("PrimaryImage")[0].Url)?width=120&height=120&mode=crop" class="img-fluid primaryImg mr-3" alt="@(String.IsNullOrEmpty(item_authors.GetFiles("PrimaryImage")[0].Title) ? item_authors.GetFiles("PrimaryImage")[0].Filename : item_authors.GetFiles("PrimaryImage")[0].Title)"/>
                                </a>
                            }
                        }
                        <div class="media-body">
                            <h5>
                                <a href="/author/@item_authors.Href">
                                    @if(!item_authors.IsDBNull("PreferredName")) {
                                        <span>@item_authors["PreferredName"]</span>
                                    } else {
                                        <span>@item_authors["FirstName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("MiddleName")) {
                                        <span>@item_authors["MiddleName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("LastName")) {
                                        <span>@item_authors["LastName"]</span>
                                    }
                                    @if(!item_authors.IsDBNull("NameSuffix")) {
                                        <span>@item_authors["NameSuffix"]</span>
                                    }
                                </a>
                            </h5>
                            @if(!item_authors.IsDBNull("Description")) {
                                <p>@item_authors.GetString("Description").Summarize(250)</p>
                            }
                            <div class="social">
                                @if(!item_authors.IsDBNull("Email")) {
                                    <span><a href="mailto:@item_authors["Email"]" class="email"
                                        data-toggle="tooltip" title="Email"
                                    ></a></span>
                                }
                                @if(!item_authors.IsDBNull("Links") && item_authors.GetRecordList("Links").Count > 0) {
                                    foreach(EngineRecord item_authors_links in item_authors.GetRecordList("Links")) {
                                        if(!item_authors_links.IsDBNull("Type")) {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="@item_authors_links.GetCategory("Type")[0].Label.ToLower()" target="_blank"
                                                    data-toggle="tooltip" title="@item_authors_links.GetCategory("Type")[0].Label" 
                                                ></a></span>
                                            }
                                        } else {
                                            if(!item_authors_links.IsDBNull("Link")) {
                                                <span><a href="@item_authors_links["Link"]" class="website" target="_blank"
                                                    data-toggle="tooltip" title="Link" 
                                                ></a></span>
                                            }
                                        }
                                    }
                                }
                            </div>
                        </div>
                    </div>
                }
            </div>
        }
    </div>)
</div>

<script src="/files/content/www/lightbox/lightbox.min.js"></script>
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a Photo Albums Lister displaying the Primary Image of each album, -->
<!--and a snippet of the Summary (or Body) field. A sidebar loads the Photo Album Topics. -->
<!--Both the Photo Albums View and Topics Category need to be created. -->
<!--The instructions are below. -->
<!--If you add this code to a page, it can be your "Photo Albums" page.-->

<!--This code block creates a lister page of the existing Photo Albums.-->
<!--A column on the right side allows your visitors to filter by topic.-->

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

<!--To use this code you MUST do the following:-->

<!--1 - create the "Photo Album Topics" Category:-->

<!--    In the dashboard main menu, click Admin > Categories. Click the green "+New Category Type" button on the right, and name it "Photo Album Topics".-->
<!--    Click save. You may now create the topics for your Photo Albums.-->
<!--    Save your edits.-->
    
<!--2 - To create/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 "PhotoAlbums" 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 "Photo Albums" (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="PhotoAlbumTopics" CatType="Photo Album Topics" Name="Topics" Cmd="After:Keywords" />-->
<!--    </FieldSet>-->
    
<!--    If you've previously made edits to the View, all you need to do is include the <Category> lines inside the "ArticleFields" fieldset.-->
    
<!--    Save the view-->

<!--3 - In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > lightbox-->
    
<!--    Download the following file and upload them to the "lightbox" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/lightbox/photoalbum.css-->

@section head {
    <link href="/files/content/www/lightbox/photoalbum.css" rel="stylesheet"/>
}


<div class="row">
    <div class="col-sm-3 order-sm-2">
        @BRT.CategoryList(tableId:"Content", viewId:"PhotoAlbums", fieldId:"PhotoAlbumTopics", 
        template: 
        @<div class="topic-list-wrap">
            <h4 class="topic-list">Topics</h4>
            <p><a href="/photo-albums">All</a></p>
            @foreach(EngineRecord c in item) {
                <p><a href="/photo-albums?topic=@c["Id"]">@c["Label"]</a></p>
            }
        </div>)
    </div>
    <div class="col-sm-9">
        <div id="photogalleries">
            @BRT.Lister(tableId:"Content", viewId:"PhotoAlbums",
            fields: new[] {"Title","PubDate","PrimaryImage","Summary","Body","PhotoAlbumTopics","HideOnPhotoAlbumsPage"},
            condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[PhotoAlbumTopics.Id]='" + Request.QueryString["topic"] + "'")),
            sortFields: new EngineCore.Meta.SortFieldMeta[] {new EngineCore.Meta.SortFieldMeta {FieldId = "PubDate", Descending=true}}, 
            template: 
            @<div class="row">
                @foreach(EngineRecord record in item) {
                    <div class="col-lg-4 col-md-6 col-xs-12">
                        <div class="albumbox">
                            @if (record.GetFiles("PrimaryImage").Count>0) {
                                <a href="/album/@record.Href"><img class="img-fluid" src="@record.GetFiles("PrimaryImage")[0].Url?width=468&height=468&mode=crop&enlarge=true" /></a>
                            }
                            <a href="/album/@record.Href">
                                <div class="albumdeets">
                                    <h5 class="albumtitle">@record.GetString("Title")</h5>
                                    @if (!record.IsDBNull("Summary")) {
                                        <p class="albumsummary">@record.GetString("Summary")</p>
                                    }
                                </div>
                            </a>
                        </div>
                    </div>
                }
            </div>)
        </div>
    </div>
</div>
                        
@*-------------------------------
@Site["ProperSiteName"]
---------------------------------*@
                        
<!--A Detail page is a template to be used for a particular type of content. -->
<!--This code creates a Resource Article Detail page that will be used to display each Resource Article. -->
<!--In order to work with the Resources (Lister Page) code block, the Friendly URL of this page should be "resource".-->

<!--This code block creates a News article page including topics.-->
<!--The code detects the presence of Primary Images, and if there is more than one, it'll automatically create a carousel.-->

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

<!--To use this code you MUST do the following:-->

<!--In the Files Manager, make sure you have the following folder structure (create the folders if you don't): -->
    
<!--    Home > content > www > slick-->
    
<!--    Download the following files and upload them to the "slick" folder:-->
    
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/ajax-loader.gif-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick-carousel.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.css-->
<!--    https://www.brickriver.com/files/central_assets/forcodesnippets/slick/slick.min.js-->
    
<!--You also MUST create the "ResourceTypes" Category and add it to the View:-->

<!--- To create the ResourceTypes Category:-->

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

<!--Save your edits.-->

<!--- To 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 "Resources" view, don't worry - we can create it easily.-->
<!--Click the green "+New" button on the right side and select "I'd like to customize an existing view". -->
<!--Find "Resources" on the list and click it.-->

<!--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="ResourceTypes" CatType="Resource Types" Name="Resource Types" Multiple="true" Cmd="Before:Keywords" />-->
<!--</FieldSet>-->

<!--If you've previously made edits to the View, all you need to do is include the <Category> lines inside the "ArticleFields" fieldset.-->

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

@section head{
    <link href="/files/content/www/slick/slick.css" rel="stylesheet"/>
    <link href="/files/content/www/css/slick-carousel.css" rel="stylesheet"/>
}

@BRT.Detail(tableId: "Content", viewId: "Resources",
fields: new[] {"Title","PubDate","PrimaryImage","Body","ResourceTypes",
"PrimaryContact","Location","Address1","Address2","City","State","Zip","Phone","Email","Files"},
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("ResourceTypes")) && item.GetCategory("ResourceTypes").Count > 0) {
                <span> - </span>
            }
            @if (!item.IsDBNull("ResourceTypes") && item.GetCategory("ResourceTypes").Count > 0) {
                <div class="topics">
                    @foreach(CategoryFieldItem topic in item.GetCategory("ResourceTypes")) {
                        <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" />
                        </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>
    @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>
    }
</article>)

<script src="/files/content/www/slick/slick.min.js"></script>
<script>
    // initialize carousel
    $('.in-page-carousel').slick({
        slidesToShow: 1
        , autoplay: false
        , dots: false
    });
    $(".slick-prev, .slick-next").text("");
</script>
                        
<!--A Lister is a block of code that loads a list of records from a specific view. -->
<!--This code creates a Resources Lister containing Title, Primary Image (if present), -->
<!--and Summary (in the absence of Summary, it loads partial content of the Body). -->
<!--If you add this code to a page, it can be your "Resources" page.-->

@BRT.Lister(tableId: "Content", viewId: "Resources",
fields: new[] {"Title","PubDate","PrimaryImage","Summary","Body","Link"},
template:
@<div>
    @foreach(EngineRecord record in item) {
        string newwindow = null; 
        string link = null;
        if(!record.IsDBNull("Link")){
            link = record.GetString("Link");
            newwindow=" target=\"_blank\" ";
        }  else {
            link = "/resource/" + record.Href;
        }
        <article class="media">
            @if(!record.IsDBNull("PrimaryImage") && record.GetFiles("PrimaryImage").Count > 0) {
                    if(record.GetFiles("PrimaryImage")[0].ContentType.StartsWith("image/")) {
                        <a href="@link" @newwindow>
                            <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="@link" @newwindow>
                        @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("ResourceTypes")){
                        <span> - </span>
                    }
                    @if (!record.IsDBNull("ResourceTypes") && record.GetCategory("ResourceTypes").Count > 0) {
                        <div class="topics">
                            @foreach(CategoryFieldItem topic in record.GetCategory("ResourceTypes")) {
                                <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>)
                        
@*
This is the part that goes into a page and it's calling news articles.
*@

@BRT.Lister(tableId:"Content", viewId:"News", fields: new[] {"Title", "PubDate", "Body", "Friendly"},   
pageSize:50,
itemTemplate:
@<item> 
    <title>@item["Title"]</title>
    @BRT.Raw("<link>PUT IN THE LINK TO THE NEWS PAGE HERE - OR WHATEVER PAGE</link>")
    <guid>http://www.[YOUR DOMAIN]/newsdetail/@item.Href</guid>
    
    @if(!@item.IsDBNull("Body")){
        <description>@item.GetString("Body").Summarize(100)</description>
    }
    else
    {
        <description>no description</description>
    }
    
    @if(!@item.IsDBNull("PubDate")){
        <pubDate>@item.GetDateTime("PubDate").ToString("R")</pubDate>
    }  

</item>)
                        
@*
You need two parts to make an RSS Feed.
You put this in the layout.
Then you make a page that uses this layout and pulls specific data.
*@

@functions{

    public override void InitializePage() {
        base.InitializePage();
        Response.ContentType="application/rss+xml";

    }

}
<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <link>PUT IN THE URL TO YOUR SITE OR MAIN CONTENT PAGE HERE</link>
        <title>@Title</title>
        <description>@Title</description>
        <language>en-us</language>
        <lastBuildDate>@DateTime.Now.ToString("R")</lastBuildDate>
        @RenderBody()
    </channel>
</rss>
                        
@functions {

    protected int radius;
    
    public override void InitializePage() {
        base.InitializePage();     
        
        if (String.IsNullOrEmpty(Request.QueryString["radius"]) || !int.TryParse(Request.QueryString["radius"], out radius)) {
            radius = 1;
        }
        
    }
}

<div>
    <form method="get" action="thispage">
        <p><input type="text" name="zip" value="@Request.QueryString["zip"]" placeholder="and/or enter zip code" /></p>
        <p>
            <select name="radius" class="form-control">
                @foreach(int i in new int[] {1,5,10,25,50,100}) {
                    <option value="@i" selected="@(i == radius ? "selected" : "")">@i miles</option>
                }
            </select>
        </p>
        <p>
            <button class="btn btn-default" type="submit">Search</button>
        </p>
    </form>
</div>

@if(!String.IsNullOrEmpty(Request.QueryString["search"]) || !String.IsNullOrEmpty(Request.QueryString["zip"])){
@BRT.Index(tableId:"Contacts",viewId:"PUTINYOURVIEWID",pageSize:50,fields: new[] {"Name","PhysCity"}, 
condition: (String.IsNullOrEmpty(Request.QueryString["zip"]) ? null : ConditionMeta.Parse("<Distance FieldId=\"PhysZip\" Zip=\"" + Request.QueryString["zip"] + "\" Radius=\"" + radius.ToString() + "\"/>")),
itemTemplate:
@<div>
    <h4><a href="/whateverdetail/@item.Href"><b>@item["Name"].ToString() - @item["PhysCity"]</b></a></h4>
    <hr/>
</div>)

}
                        
<!--Use this code in a page where there is a lot of content and you want people to be able to find what they need quickly. -->
<!--A good example is a page that contains a long list of people.-->


<form method="GET">
    <input type="text" name="search" id="search" class="form-control" placeholder="type to search" autofocus="true"/>
</form>

<!--Insert the lister that will generate the content here. Make sure that each searchable div has the class "snippet"/-->


<!--Below everything else-->
<script type="text/javascript" src="/files/content/www/js/jquery.quicksearch.js"></script>
<script type="text/javascript">
    $('input#search').quicksearch('.snippet');
</script>
                        
<!--** This will only work after you create your Site Indexes. ** -->
<!--Use this search when you want to allow your visitors to search for content throughout your website. -->
<!--You need to have a page called "Search Results" (friendly url: "search-results") with the search code in order for this to work. -->
<!--The submission form code below can be inside the Search Results page as well as in other pages/layouts.-->


<!--SITEWIDE SUBMISSION FORM CODE-->
<!--Place this code where you want the search form to appear, this can be in any page or layout-->

<div id="searchdiv"> 
    <form action="/search-results" class="f-form">
        <div class="input-group">
            <input type="text" name="q" class="form-control" id="gsearchbox" placeholder="Search">
            <div class="input-group-prepend">
                <button class="input-group-text" id="gsearchbutton" type="submit"><i class="fas fa-search"></i></button>
            </div>
        </div>
    </form>
</div>  

<!--SEARCH RESULTS PAGE SUBMISSION FORM CODE-->
<!--Place this code in the Search Results page where you want the search form to appear-->

<form>
    <input type="text" name="q" value="@(Request.QueryString["q"])"/>    
    <input type="submit" value="Search"/>
</form>

<!--RESULTS DIV-->
<!--Place this code in the Search Results page where you want the results to appear-->

<div id="results"></div>


<!--SEARCH CODE-->
<!--Make sure this code is at the top of the Search Results page-->

@BRT.SearchResultsScript()
                        
************Secure URL************

 string re = "http://www.brickriver.com" +  SecureUrlFunctions.GenerateSecureUrl("/dashboard/loginas/" + rec.GetRecordList("Church")[0].Id.Value);

Check for secure URL
BRT.RenderContext.IsSecureUrl

**************Console Link**************

SecureUrlEncryptor secURL = new SecureUrlEncryptor();
string consoleLink =  "https://" + CustomerContext.Current.ShortName + ".brtapp.com" + secURL.GetSecureAction(SecureUrlFunctions.SecureUrlActions.DeepLink, "manage/contacts-appointmenttoolpeople#," + p.Id.ToString());
                        
EngineCore.EngineEmail.ModuleEngineEmail(body:x subject:x, fromAddress:x, fromName:x, recipients:x, replyTo:x);


**********SEND EMAIL*********

var email = new EngineEmail();
    
email.FromAddress = FromAddress;
    
email.FromName = FromName;
    
email.AddressRecipients.Add(AddressRecipients);
    
email.Subject = "A Gift of Hope";
    
email.Body = EmailBody;
    
email.Send();
                        
@*--------Add this to the the helper --------------------
options:DataHelperExtensions.DataHelperOptions.ShowInvisible,
*@
                        
@BRT.SiteNav(
template:
@<div class="dropdown inner">
    <button class="btn btn-secondary dropdown-toggle btn-block" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    @item.Title Menu
    </button>
    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    @foreach(SiteNavHelperExtensions.SiteNavItem nv in item.Children) {
        <a class="dropdown-item" href="/@nv.Friendly" style="text-decoration:none;">@nv.Title</a>
    }
    </div>
</div>)

OR USE:  @BRT.SiteHomeNav()
                        
new EngineCore.Meta.ConditionMeta.CompareCondition {FieldId = "Calendar", Op = EngineCore.Meta.ConditionOperators.Equal, Value= new EngineCore.Meta.ConditionMeta.ConstantValue {Value = "2886"}}}},
sortFields: new EngineCore.Meta.SortFieldMeta[] {new EngineCore.Meta.SortFieldMeta {FieldId = "StartDate", Descending=false}},
template:  
@<ul class="nav nav-tabs nav-stacked">                                
    @foreach(EngineCore.Data.EngineRecord record in item) {        
          <li><a href="/eventdetail/@record.Href"> 
          @if(!@record.IsDBNull("StartDate")){
           @(record.GetDateTime("StartDate").ToString("d") + ":")
            }
            @if(!@record.IsDBNull("Title")){
                @record.GetString("Title")
            }
            @if(@record.IsDBNull("Title")){
                @("No Title")
            }
           </a></li>                                
    }                        
</ul>)
                        
***Sort Files***
@{var photos = item.GetFiles("Photos");} 
           
@if(photos.Count > 0) {
   
    photos.Sort((x,y) => (string.IsNullOrEmpty(x.Title) ? x.Filename : x.Title)
        .CompareTo((string.IsNullOrEmpty(y.Title) ? y.Filename : y.Title)));
    
    <div class="card-columns">
        @foreach(FileFieldItem f in photos){
            if(f.ContentType.StartsWith("image/")) {
            <a href="@f.Url?width=1200&height=800" data-lightbox="gallery" data-title="@(!String.IsNullOrEmpty(f.Title)? f.Title: "") @(!String.IsNullOrEmpty(f.Description)? "- " + f.Description: "") <br/><a href='@f.Url'>Download image</a>" >
                 <div class="card card-inverse" style="text-align:center;">
                   <img src="@f.Url?width=700&height=700" class="card-img-top img-fluid" alt="@f.Description" />
                
                @if(!String.IsNullOrEmpty(f.Title)){
                <div class="card-img-overlay" style="text-align:left">
                    <small>@f.Title</small>
                    @*
                    @if(!String.IsNullOrEmpty(f.Description)){
                        <span> - @f.Description</span>
                    }
                    *@
                </div>
                }
            </div></a>
            }
        }
    </div>    

            }
                        
*********SORT EngineRecordList ON CustomField **************

@functions{

System.Collections.Generic.List<EngineRecord> recList(EngineRecordList rlist){
    System.Collections.Generic.List<EngineRecord> l = new System.Collections.Generic.List<EngineRecord>();

    foreach(EngineRecord r in rlist){
        l.Add(r);
    }


    l.Sort(delegate(EngineRecord x, EngineRecord y){
        	if (x.GetRecordList("People").Count == 0 && y.GetRecordList("People").Count== 0) return 0;
        
	else if(x.IsDBNull("People") || x.GetRecordList("People").Count == 0) return -1;
        
	else if(y.IsDBNull("People") || y.GetRecordList("People").Count == 0) return 1;
        
	else if (x.GetRecordList("People")[0].GetString("LastName") == "") return -1;
        
	else if (y.GetRecordList("People")[0].GetString("LastName") == "") return 1;
        
	else if (y.GetRecordList("People")[0].GetString("LastName") == x.GetRecordList("People")[0].GetString("LastName")) return x.GetRecordList("People")[0].GetString("FirstName").CompareTo(y.GetRecordList("People")[0].GetString("FirstName"));
        
	else return x.GetRecordList("People")[0].GetString("LastName").CompareTo(y.GetRecordList("People")[0].GetString("LastName"));
    });
            
    // l.Reverse();
    return l;
  
}

}
                        
<form id="regform" method="post" action="https://CUSTNAME-email.brtapp.com/subscribe" target="_blank">
    <div class="input-group">
        <input type="text" class="form-control" placeholder="enter your email address" aria-label="Subscriber's email address" aria-describedby="subscribe" onfocus="if (this.value == 'your email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your email address';}">
        <div class="input-group-append">
            <span class="input-group-text" id="subscribe">Subscribe</span>
        </div>
    </div>
</form>