creating list in widget studio

Hello everybody,

It seems I have a problem creating a custom list in telligent, I'm trying to create a custom list with groups in the order that I want to(not ascending or descending). The difficult part is that I'm trying to construct it by index, so when I loop through it, it is already ordered the way I want it to, but unfortunately nothing seems to work, I have a sample code explaining what I tried.


#set($arr = []) ## I'm initializing the list

## trying to manually add items in the order that I wish

$arr.set(1, "text") -- not working

$arr.add("text") ## working  
$arr.add(0, "text") ## not working by with index
#set($arr[0] = "text") ## not working
$arr.insert(0, "text") ## not working 
$arr.put(0, "text") ## not working

Do you guys have any suggestions? I have also looked into the official Velocity documentation, but it doesn't seem to necessarily be on point with the Telligent widget velocity.

Any help would be appreciated, thank you!

  • An inline declared list is really a .net ArrayList object behind the scenes. Add(object), and Insert(int, object) are available. (ArrayList .net documentation:

    Within widget studio, you can also use the $core_v2_utility.Describe(object) API within the sandbox to identify all properties and methods available on any entity. For example,



    • [ArrayList]
      • Capacity: 0 [Int32]
      • Count: 0 [Int32]
      • IsFixedSize: False [Boolean]
      • IsReadOnly: False [Boolean]
      • IsSynchronized: False [Boolean]
      • SyncRoot [Object]
        • Equals(Object obj) [Boolean]
        • GetHashCode() [Int32]
        • GetType() [Type]
        • ToString() [String]
      • Add(Object value) [Int32]
      • AddRange(ICollection c) [Void]
      • BinarySearch(Int32 index, Int32 count, Object value, IComparer comparer) [Int32]
      • BinarySearch(Object value) [Int32]
      • BinarySearch(Object value, IComparer comparer) [Int32]
      • Clear() [Void]
      • Clone() [Object]
      • Contains(Object item) [Boolean]
      • CopyTo(Array array) [Void]
      • CopyTo(Array array, Int32 arrayIndex) [Void]
      • CopyTo(Int32 index, Array array, Int32 arrayIndex, Int32 count) [Void]
      • GetEnumerator() [IEnumerator]
      • GetEnumerator(Int32 index, Int32 count) [IEnumerator]
      • GetRange(Int32 index, Int32 count) [ArrayList]
      • IndexOf(Object value) [Int32]
      • IndexOf(Object value, Int32 startIndex) [Int32]
      • IndexOf(Object value, Int32 startIndex, Int32 count) [Int32]
      • Insert(Int32 index, Object value) [Void]
      • InsertRange(Int32 index, ICollection c) [Void]
      • LastIndexOf(Object value) [Int32]
      • LastIndexOf(Object value, Int32 startIndex) [Int32]
      • LastIndexOf(Object value, Int32 startIndex, Int32 count) [Int32]
      • Remove(Object obj) [Void]
      • RemoveAt(Int32 index) [Void]
      • RemoveRange(Int32 index, Int32 count) [Void]
      • Reverse() [Void]
      • Reverse(Int32 index, Int32 count) [Void]
      • SetRange(Int32 index, ICollection c) [Void]
      • Sort() [Void]
      • Sort(IComparer comparer) [Void]
      • Sort(Int32 index, Int32 count, IComparer comparer) [Void]
      • ToArray() [Array-of-Object]
      • ToArray(Type type) [Array]
      • TrimToSize() [Void]
  • Comparing it to a .net object clears the confusion, thank you!

  • How to create Key value pair list in velocity Telligent?

  • Hi . What version of Community are on? I ask, since if you are on version 11 or later, you can use server-side JavaScript instead of Velocity in any use case Velocity is also available, and this is typically much easier for use cases that involve manipulation of data within a script instead of just basic templating of output as in Velocity.

    If you must use Velocity, a common pattern is to define an IDictionary that could be accepted by an API as follows:

    #set ($items = "%{}")
    $items.Add('key1', 'value1')
    $items.Add('key2', 'value2')