@BRT.Index()

Displays a set of EngineRecords retrieved from a designated View

Both @BRT.Index() and @BRT.Lister() retrieve a list of EngineRecords from a View and optionally - render record data on a page using the 'template:' parameter.
The primary difference between the two is that @BRT.Index() will create links to navigate between multiple pages of records and @BRT.Lister() does not.
For example, if @BRT.Index() is used to retrieve records from an Blogs View that contains 50 records - adding the parameter  'pageSize:10' will cause the the Helper to display the first ten records with links to Page 2 through Page 5 to display the additional 40 records.
Page navigation links are rendered using the CSS Class: brt-pagination, as follows:
<div>
<span>Page 1 of 3</span>
<span> <a href="/friendly">1</a>
<a href="/friendly?page=2">2</a>
<a href="/friendly?page=3">3</a>
<a href="/friendly?page=2">next</a>
</span>
</div>
Add class definitions to local CSS files to customize brt-pagination, for example:
.brt-pagination {
    display:block;
    clear:left;
    padding-top:20px;
}
.brt-pagination a {
    margin-left:7px;
    padding:4px 7px;
    border:1px solid #ddd;
}
Required Parameters
fields: A list of fields values retrieved from a View
Example: fields: new[] {"PrimaryImage","Name","Summary,"Description"}
The fields: parameter is used retrieve field values from EngineRecord items.  It is used in several Helpers and it is always dependent on the viewId: parameter.
This parameter creates an array of values based based on field Id names available in the View that is indicated by the viewId parameter, using the following syntax.
fields: [ ] {"field Id", "fieldId", "fieldId" "fieldild",...}
Each "field Id" must indicate a valid Column Id, Category Id, CustomField Id or Relationship Id in the relevant View.
For a Column Id, Category Id or CustomField Id use the Id in quotes: fields:[] {"Type","BoardTitle","Name"}
For a Relationship Id, there are two uses.
  1. The RelationshipID in quotes:  fields:[] {"Authors"}
  2. The RelationshipID followed by ID's of fields of child elements, in quotes: fields:[] {"Authors.Name", "Authors.PrimaryImage","Authors.Summary"}
A Helper will fail if the fields: parameter includes a field Id not included in the View named in the ViewId: parameter
For example, if your system includes a View named "Employees"  and that view creates a Custom Field with a CustomField Id of "DateOfHire", the following BRT.Index Helper will fail:
@BRT.Index(tableId:"Contacts", viewId:"People",
                    fields: new[] {"Name", "PrimaryImage","Email","DateOfHire"} ...
because the People View does not include "DateOfHire" field.
The following BRT.Index Helper will succeed:
@BRT.Index(tableId:"Contacts", viewId:"Employees",
                    fields: new[] {"Name", "PrimaryImage","Email","DateOfHire"} ...
tableId: Names the base table to be targeted by the Helper, almost always: "Content" or "Contacts"
Example: tableId:"Content"
The tableId: parameter is used to name the base table that contains records to be retrieved by the Helper.  This is most commonly the "Content" or "Contacts" tables.
Less frequently used tableId values are:
  • tableId: "Users"
  • tableId: "RegForms"
  • tableId: "Emails"
  • tableId: "EmailNewsletter"
  • tableId: "EmailArchives"
viewId: Indicates the View which contains the record set to be targeted by the Helper
Example: viewId:"BlogPosts"
The viewID: parameter indicates the View targeted by the Helper. The View can be either visible or invisible to users in the Web Console.
Optional Parameters
condition: Adds a condition to filter records retrieved
Example: condition: (String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[Topic.Label]='" + Request.QueryString["topic"] + "'"))
The condition: parameter applies a search or filter condition to limit the EngineRecords retrieved from View named in the Helper's viewId: template.
itemTemplate: Applies a Razor template to data elements retrieved by the Helper
Example: itemTemplate:
    @<div>
        <h3><a href="/trusteedetail/@item.Href">@item.GetString("Name")</a></h3>
    </div>)
The itemTemplate: parameter is always an optional parameter but virtually all Helpers that create EngineRecord items use either 'template:' or 'itemTemplate:' to style and present item content.
itemTemplate:
@<div>
Any valid HTML and Razor code
</div>)
options: provides options to override Helper defaults
Example: options:DataHelperExtensions.DataHelperOptions.PushToChildren
This parameter has two possible arguments:
  1. DataHelperExtensions.DataHelperOptions.PushToChildren - Applies the condition and savedFilter to any child records
  2. DataHelperExtensions.DataHelperOptions.ShowInvisible - Ignores the Visible savedFilter
pageSize: The number of records to return per page
Example: pageSize:10
Indicates the number Engine Records retrieve and display.
savedFilters: Applies a saved filter from the View definition
Example: savedFilters:new[] {"LocalNews"}
The savedFilters: parameter names one or more saved filters to be applied to the EngineRecords returned by a Helper.  Values must indicate valid FilterId names included in the definition of the View named in the Helper's viewId: parameter.
sortFields: A list of the fields to sort the Lister or Index records.
Example: sortFields: new EngineCore.Meta.SortFieldMeta[] {new EngineCore.Meta.SortFieldMeta {FieldId = "LastName"}},
The sortFields: parameter create a list of fields to apply a sort order to records retrieved by a Data Helper. If this parameter is not included, the EngineRecords will use the sort order of the View named in the viewId: parameter for the Helper.
Values for this parameter must be  valid ColumnId names.  Category, Custom, and Relationship fields may not be used by sort:Fields:.
template: Applies a Razor template to data elements retrieved by the Helper
Example: template:
            @<div>
            <h4>Meet our Authors!</h4>        
                        @foreach(EngineRecord c in item) {
                              <p><a href="/authordetail?type=@c.GetString("Name")">@c.GetString("Name") </a></p>
                }        
            </div>)
The template: parameter is always an optional parameter but virtually all Helpers that create EngineRecord items use either 'template:' or 'itemTemplate:' to style and present item content.
Syntax is:
template: 
@<div>
Any valid HTML and Razor code
</div>)