@BRT.CategoryList()

Retrieves a list of all categories from a category field.

@BRT.CategoryList() retrieves an EngineRecordList for each category in a category field.  Each EngineRecord contains:
  • Id
  • Label
  • Abbrev
  • BackColor
The optional 'template:' parameter is commonly used to render EngineRecord value on a Page. If no 'template;' is present, this Helper uses the following 'Default Template' to render a static list of Category Label values.
<ul><br>    @foreach(EngineRecord record in item){<br>        <li>@record.GetString("Label")</li><br>    }<br></ul>
	
Required Parameters
fieldID: Designates the Id of field
Example: fieldId:"Topic"
This parameter takes a single string argument - the Id value of the target field.
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.
count: Number of EngineRecords to return - starting with record [0].
Example: count:4
If this parameter is not used the Helper will retrieve up to 500 records.
This parameter takes a numeric value: x and retrieves the first x EngineRecords.
Note that:
  1. the first EngineRecord is number [0].  To return the first 5 EngineRecords use: count:4.
  2. most parameters take string arguments which require quotes.  This parameter arguments are strings and therefor enclosed in quotes.  This parameter takes an integer - no quotes please.
query: Provides criteria for a "Like" query on the Record Label
Example: query: "rooms"
This parameter takes a string value to form a simple Like query on the EngineRecord label value.  Wildcard characters normally allowed in Like criteria may not be used.
For example, the following Helper:
@BRT.CategoryList(tableId:"Contacts", viewId:"Facilities", fieldId:"Facility Type" ,query:"rooms" )
retrieves categories from the Facility Type Field defined in the Facilities View.  The results will include Conference Rooms, Meeting Rooms, and  Classrooms, but not Cafeterias or Reception Areas (or other categories without 'rooms' in the category label.
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>)	
Adapter
Adapter for a category like these:
<Category Id="GiftType" Name="Gift Type" CatType="Donation Gift Types" Multiple="false"  />
<Category Id="HandEnteredPaymentMethod" Name="Payment Method" CatType="Donation Payment Methods" Multiple="false"  />
Can be written as:
@{
    var adapter = EngineAdapter.Create("DonationTransactions");
    var paymentMethods = adapter.GetCatValues("HandEnteredPaymentMethod",null,100);
}
<select>
    @foreach(var pm in paymentMethods) {
    <option value="@pm["Id"]">@pm["Label"]</option>
    }
</select>
There's 3 parameters to adapter.GetCatValues("HandEnteredPaymentMethod",null,100);
The first is the field Id, so GiftType or HandEnteredPaymentMethod. It's the name of the field, not the name of the CatType.
The second parameter is a filter.
The third is how many to get.
So adapter.GetCatValues(FIELDID,null,100) should work.