FAQ with Topics (Detail Page)

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


<!--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" />-->

<!--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"},
    <small class="media-metadata text-muted">
        @if(!item.IsDBNull("PubDate")) {
        @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")) {
    @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"/>
    @if(!item.IsDBNull("Body")) {
    @if(!item.IsDBNull("Files") && item.GetFiles("Files").Count > 0) {
        <div class="box box-outline">
            @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>