FAQ (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. In order to work with the FAQs Lister Page code block, the Friendly URL of this page should be "faq".

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