From 76b23651f0781f2b18920cfe126f852655225dd7 Mon Sep 17 00:00:00 2001 From: Yuri Salimovskiy Date: Fri, 6 Oct 2023 16:07:30 +0300 Subject: [PATCH] Added `{index}` and `{total_items}` variables to options fieldtypes --- docs/fieldtypes/checkboxes.md | 25 ++++++++++++++++++++----- docs/fieldtypes/multiselect.md | 24 ++++++++++++++++++++---- docs/fieldtypes/selectable-buttons.md | 24 ++++++++++++++++++++---- 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/docs/fieldtypes/checkboxes.md b/docs/fieldtypes/checkboxes.md index 98f196a0b..72779bf9a 100644 --- a/docs/fieldtypes/checkboxes.md +++ b/docs/fieldtypes/checkboxes.md @@ -49,7 +49,7 @@ You can use a single variable for Checkboxes to render a comma-separated list of ### Variable Pair -Using a variable pair, allows for customization of the output. +Using a variable pair of field name, allows for customization of the output. {field_name} {item}
@@ -63,7 +63,20 @@ Two Three ``` -By default, `{item}` will render the item's label To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: +The following variables are available inside field's tags pair: + +| Variable | Description | +| --------------- | --------------------------------------------------- | +| `{item}` | Label of selected item | +| `{item:label}` | Label of selected item | +| `{item:value}` | Value of selected item | +| `{count}` | Counter for each of selected items, starting with 1 | +| `{index}` | Counter for each of selected items, starting with 0 | +| `{total_items}` | Total number of selected items | + +By default, `{item}` will render the item's label. + +To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: {field_name} Label: {item}
{!-- 1 --} @@ -90,7 +103,9 @@ TIP: **Tip:** It is recommended that you use the value in conditionals, as it ty TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to showing the label. Radio Buttons and Selects default to showing the value. -### Limit Parameter +### Parameters + +#### `limit` This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair. @@ -98,7 +113,7 @@ This parameter limits the number of selected items output by the tag. It works f {field_name limit="2"} {!-- One,Two --} ``` -### Markup Parameter +#### `markup` As a single tag, a checkbox will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list @@ -112,7 +127,7 @@ Which will render as
  • Orange
  • -### Backspace Parameter +#### `backspace` When used as a tag pair, checkboxes are a looping pair. Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. For example, if you put a `
    ` tag after each item you'll have this diff --git a/docs/fieldtypes/multiselect.md b/docs/fieldtypes/multiselect.md index 1793bbcaf..4033c54f6 100644 --- a/docs/fieldtypes/multiselect.md +++ b/docs/fieldtypes/multiselect.md @@ -63,7 +63,21 @@ Two Three ``` -By default, `{item}` will render the item's label. To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: + +The following variables are available inside field's tags pair: + +| Variable | Description | +| --------------- | --------------------------------------------------- | +| `{item}` | Label of selected item | +| `{item:label}` | Label of selected item | +| `{item:value}` | Value of selected item | +| `{count}` | Counter for each of selected items, starting with 1 | +| `{index}` | Counter for each of selected items, starting with 0 | +| `{total_items}` | Total number of selected items | + +By default, `{item}` will render the item's label. + +To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: {field_name} Label: {item}
    {!-- One --} @@ -90,7 +104,9 @@ TIP: **Tip:** It is recommended that you use the value in conditionals, as it ty TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to showing the label. Radio Buttons and Selects default to showing the value. -### Limit Parameter +### Parameters + +#### `limit` This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair. @@ -98,7 +114,7 @@ This parameter limits the number of selected items output by the tag. It works f {field_name limit="2"} {!-- One,Two --} ``` -### Markup Parameter +#### `markup` As a single tag, a multi select will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list @@ -112,7 +128,7 @@ Which will render as
  • Orange
  • -### Backspace Parameter +#### `backspace` When used as a tag pair, Multiselect are a looping pair. Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. For example, if you put a `
    ` tag after each item you'll have this diff --git a/docs/fieldtypes/selectable-buttons.md b/docs/fieldtypes/selectable-buttons.md index 0ab5001f4..0333405ce 100644 --- a/docs/fieldtypes/selectable-buttons.md +++ b/docs/fieldtypes/selectable-buttons.md @@ -60,7 +60,21 @@ When allowing multiple items to be selected, Selectable Buttons will usually be {item}
    {/field_name} -By default, `{item}` will render the item's label. To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: + +The following variables are available inside field's tags pair: + +| Variable | Description | +| --------------- | --------------------------------------------------- | +| `{item}` | Label of selected item | +| `{item:label}` | Label of selected item | +| `{item:value}` | Value of selected item | +| `{count}` | Counter for each of selected items, starting with 1 | +| `{index}` | Counter for each of selected items, starting with 0 | +| `{total_items}` | Total number of selected items | + +By default, `{item}` will render the item's label. + +To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable: {field_name} Label: {item}
    @@ -98,11 +112,13 @@ TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to show NOTE: **NOTE:** For Select fields used in [Custom Member Fields](control-panel/member-manager.md#custom-member-fields) and [Category Group Details Tab](control-panel/categories.md#details-tab), the modifiers are not currently available in conditionals, and _must_ be based on the value, e.g. `{if some_cat_field == 2}` -### Limit Parameter +### Parameters + +#### `limit` This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair. -### Markup Parameter +#### `markup` When allowing for multiple selections, a single tag will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list @@ -116,7 +132,7 @@ Which will render as
  • Orange
  • -### Backspace Parameter +#### `backspace` Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop when using a variable pair. For example, if you put a `
    ` tag after each item you'll have this