List Tags

List Set

Sets a list. To set the keys, separate key => value pairs by =>.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • trim=: Trim the tagdata? Can be "yes" or "no". The default is "yes".
  • delimiter=: The list item delimiter (the character used to separate the list items). Defaults to "|".
  • remove_empty=: Remove empty list items? Can be "yes" or "no". The default is "yes".

Example

{!-- sets a list --}
{exp:ce_vars:list_set name="test"}
some item|another item|yet another item
{/exp:ce_vars:list_set}

{!-- sets a list of key => value pairs --}
{exp:ce_vars:list_set name="test"}first=>a|second=>b|third=>c{/exp:ce_vars:list_set}

List Set Pre Content

Allows pre content to be saved for a list. This content will automatically be prepended to the lists contents anytime a list is requested via the List Get tag.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • trim=: Trim the whitespace from the passed in content? Can be "yes" or "no". The default is "yes".
  • print=: Should the tagdata content be returned afterward? Can be "yes" or "no". The default is "no".

Example

{exp:ce_vars:list_set_pre_content name="test"}
<p>This will show up before the list content.</p>
{/exp:ce_vars:list_set_pre_content}

List Set Post Content

Allows post content to be saved for a list. This content will automatically be appended to the lists contents anytime a list is requested via the List Get tag.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • trim=: Trim the tagdata? Can be "yes" or "no". The default is "yes".
  • print=: Should the tagdata content be returned afterward? Can be "yes" or "no". The default is "no".

Example

{exp:ce_vars:list_set_post_content name="test"}
<p>This will show up after the list content.</p>
{/exp:ce_vars:list_set_post_content}

List Get

Outputs the contents of a list.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • flatten=: Flatten multidimensional lists? Can be "yes" or "no". The default is "no".
  • unique=: Make the list items unique by removing duplicates? Can be "yes" or "no". The default is "yes".
  • offset=: List offset. Default is 0.
  • limit=: Limit the number of list items. There is no limit by default.
  • sort=: Can be "asc" or "desc". There is no sorting by default.
  • glue=: Text to join the list items together. Default is ', '.
  • keys=: Limit the list to only consist of certain array keys. Delimited by '|'.

Example

{!-- set the test list --}
{exp:ce_vars:list_set name="test"}
some item|another item|yet another item
{/exp:ce_vars:list_set}

{!-- get the test list --}
{exp:ce_vars:list_get name="test"}

The above would return: some item, another item, yet another item

List Contains

Determine if the list contains the specified item. This tag will return boolean values so it can be used in conditionals.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • flatten=: Flatten multidimensional lists? Can be "yes" or "no". The default is "no".
  • unique=: Make the list items unique by removing duplicates? Can be "yes" or "no". The default is "yes".
  • offset=: List offset. Default is 0.
  • limit=: Limit the number of list items. There is no limit by default.
  • sort=: Can be "asc" or "desc". There is no sorting by default.
  • keys=: Limit the list to only consist of certain array keys. Delimited by '|'.

Example

{if '{exp:ce_vars:list_contains name="test" item="another item"}' }yes, the item exists{/if}

List Loop

Loops through the list items.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • flatten=: Flatten multidimensional lists? Can be "yes" or "no". The default is "no".
  • unique=: Make the list items unique by removing duplicates? Can be "yes" or "no". The default is "yes".
  • offset=: List offset. Default is 0.
  • limit=: Limit the number of list items. There is no limit by default.
  • sort=: Can be "asc" or "desc". There is no sorting by default.
  • keys=: Limit the list to only consist of certain array keys. Delimited by '|'.

Tag Variables

These variables are available in your tag to control the output.

  • {count}: The “count” out of the current item being displayed.
  • {total_results}: The total number of items being displayed..
  • {list:key}: The list item’s key.
  • {list:item}: The list item’s value.
  • {list:value}: The list item’s value.
  • {no_results}There were no results.{/no_results}: Anything in this pair will be returned if no entries are found or returned.

Example

{exp:ce_vars:list_loop name="test" sort=""}
<p>Here is item {count} of {total_results}: {list:item}</p>
{/exp:ce_vars:list_loop}

List Count

Returns the number of items in the list.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • flatten=: Flatten multidimensional lists? Can be "yes" or "no". The default is "no".
  • unique=: Make the list items unique by removing duplicates? Can be "yes" or "no". The default is "yes".
  • offset=: List offset. Default is 0.
  • limit=: Limit the number of list items. There is no limit by default.
  • sort=: Can be "asc" or "desc". There is no sorting by default.

Tag Variables

  • {count}: The “count” out of the current item being displayed.
  • {total_results}: The total number of items being displayed..
  • {list:key}: The list item’s key.
  • {list:item}: The list item’s value.
  • {list:value}: The list item’s value.
  • {no_results}There were no results.{/no_results}: Anything in this pair will be returned if no entries are found or returned.

Example

The count: {exp:ce_vars:list_count name="test"}

List Remove

Remove a list.

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.

Example

{exp:ce_vars:list_remove name="test"}

List To Global

Sets each item in a list to a global variable. The global variables will be in the format list_name.count

Parameters

  • name= (required): The list name. You can also use dot notation syntax for nested items.
  • flatten=: Flatten multidimensional lists? Can be "yes" or "no". The default is "no".
  • unique=: Make the list items unique by removing duplicates? Can be "yes" or "no". The default is "yes".
  • offset=: List offset. Default is 0.
  • limit=: Limit the number of list items. There is no limit by default.
  • sort=: Can be "asc" or "desc". There is no sorting by default.

Example

{exp:ce_vars:list_to_global name="test"}