Many times in your Dreamweaver Template you want to count the number of field values of a multivalued field, or the number of Components in an array.
There is a way to count a collection in the Package, but the documentation regarding the built-in functions available within Dreamweaver templates is not very extensive.
There is a way to count a collection in the Package, but the documentation regarding the built-in functions available within Dreamweaver templates is not very extensive.
Before you start writing a .NET Template that counts a collection and pushes this number into a Package Item, take a look at:
[TemplateCallable]
public int
CollectionLength(string expression)
The expression passed to the method equals the fully qualified name of the Package Item and a value selector.
The following example will return the number of values of the paragraphs field.
@@CollectionLength("Component.Fields.paragraphs")@@