FAQs (Lister Page)

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.

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