Event with Related Content (Detail Page)

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 included in the beginning of the code as comments. In order to work with the Events Helper, the Friendly URL of this page should be "event".

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