Skip to content

Commit d5f37c5

Browse files
authored
Merge pull request #1053 from nep/Pro-Variables-doc-cleanup
Pro variables doc cleanup
2 parents 9828563 + b234035 commit d5f37c5

File tree

6 files changed

+89
-55
lines changed

6 files changed

+89
-55
lines changed

docs/add-ons/pro-variables/fieldtype.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ The value of the field will be the _variable name_, for example: `my_var`. To ou
2727

2828
## Examples
2929

30-
Say you have 5 different testimonial quotes stored as variables in the variable group Quotes, named `lv_quote_1` to `lv_quote_5`. To each News entry, you want to add one of those quotes. Then add a Pro Variables field to your News field group, eg. `news_quote`. Then select the Quotes group in the field settings. To output the quote, you’d need code like this:
30+
Say you have 5 different testimonial quotes stored as variables in the variable group Quotes, named `pv_quote_1` to `pv_quote_5`. (Remember, you can create these in one pass using the (suffix option)[/add-ons/pro-variables/manage.md#variable-creation-options].)
31+
32+
To each News entry, you want to add one of those quotes. Then add a Pro Variables field to your News field group, eg. `news_quote`. Then select the Quotes group in the field settings. To output the quote, you’d need code like this:
3133

3234
{exp:channel:entries channel="news"}
3335
<h2>{title}</h2>
@@ -54,4 +56,4 @@ If you’re allowing for multiple selections, you can use the channel field as a
5456
{news_quotes}
5557
<blockquote><p>{{var}}</p></blockquote>
5658
{/news_quotes}
57-
{/exp:channel:entries}
59+
{/exp:channel:entries}

docs/add-ons/pro-variables/manage.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ There are a couple of extra properties you can assign to variables, other than t
1717

1818
### Variable name
1919

20-
Name of the variable you can use in your templates. Example: `lv_my_special_var`.
20+
Name of the variable you can use in your templates. Example: `pv_my_special_var`. You can use (`{suffix}`)[#variable-creation-options] in this setting.
2121

2222
### Variable label
2323

24-
The label a user sees when editing the contents of the variable.
24+
The label a user sees when editing the contents of the variable. You can use (`{suffix}`)[#variable-creation-options] in this setting.
2525

2626
### Variable notes
2727

@@ -37,21 +37,27 @@ You can hide variables from regular users (non-managers) on a per-variable basis
3737

3838
### Early parsing
3939

40-
You can enable early parsing on a per-variable basis.
40+
You can enable early parsing on a per-variable basis, if this is enabled overall in Pro Variable settings.
4141

4242
### Variable type
4343

4444
Choose any variable type that suits your needs best. [Here’s a list of variable types that come with Pro Variables.](/add-ons/pro-variables/type.md) Each type will reveal additional type-specific properties.
4545

4646
## Variable creation options
4747

48-
When creating a new variable, you have two extra options you can use. First, you can **set the initial value** of the variable, so it has a value upon creation. Second, you can enter any amount of **suffixes**, separated by a space. A new variable will be created for each suffix entered, each with identical settings apart from the suffix.
48+
When creating a new variable, you have two extra options you can use.
49+
50+
First, you can **set the initial value** of the variable, so it has an existing value upon creation.
51+
52+
Second, you can enter any amount of **suffixes**, separated by a space. A new variable will be created for each suffix entered, each with identical settings apart from the suffix.
4953

5054
When using the suffix option, you can use `{suffix}` in both the variable name as the variable label. This will be replaced by the actual suffix upon creation.
5155

56+
NOTE: You can use this for language options (en fr de nl), for creating a set of numbered fields (1 2 3 4), for creating a collection of fields for social media links (fb tiktok instagram linkedin), and more.
57+
5258
## Variable groups
5359

54-
You can create any number of groups to organize your variables. These groups will appear in the Group drop down for each variable, so you can assign a group to it. On the module home page, variable managers can sort the groups using drag and drop. Variable managers can also edit and delete the groups from here, by clicking on the edit or delete icon next to the group name. You can alter the variable order in a group by editing the group’s properties.
60+
You can create any number of groups to organize your variables. These groups will appear in the Group dropdown for each variable, so you can assign a group to it. On the module home page, variable managers can sort the groups using drag and drop. Variable managers can also edit and delete the groups from here, by clicking on the edit or delete icon next to the group name. You can alter the variable order in a group by editing the group’s properties.
5561

5662

5763
### Group label
@@ -81,4 +87,4 @@ If you want to duplicate the group variables, enter a single suffix to be applie
8187

8288
## Suffix options
8389

84-
You can choose to either _append_ the suffix to each new variable, or to _replace_ an existing suffix for each new variable. Please note that the suffix is considered to be the part of the variable name _after the last underscore_.
90+
You can choose to either _append_ the suffix to each new variable, or to _replace_ an existing suffix for each new variable. Please note that the suffix is considered to be the part of the variable name _after the last underscore_.

docs/add-ons/pro-variables/settings.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@
1313

1414
### Select Variable Managers
1515

16-
Select the member groups that are allowed to manage the variables, rather than just editing their contents.
16+
Select the member groups that are allowed to manage the variables (create, modify settings, delete), rather than just editing their contents. Overall access to Pro Variables is controled in the Member Role settings under "Allowed add-on access," but by default only Super Admins can manage variables -- all other member roles will only have access to edit the variables.
1717

1818
### Clear cache
1919

20-
If set to Yes, all native cache will be cleared after variables are saved. If set to Ask, a checkbox will appear next to the Save Changes button to optionally clear the cache. It will be unchecked by default with opt-in, checked by default with opt-out.
20+
If set to No, changing a Pro Variable will never clear the cache. If set to Yes, all native cache will be cleared whenever any variables are saved. If set to "Optionally", you will see two buttons: "Save Variables" and "Save and Clear Cache" to optionally clear the cache.
2121

2222
### Enable early parsing?
2323

24-
Choose if variables can be parsed early in the parsing order; before or after existing Snippets and config-variables. Yes, before Snippets will parse early parsed Pro Variables before Snippets and variables set in config.php; Yes, after Snippets will parse them after.
24+
This controls the overall ability for Pro Variables to be parsed early in the parsing order. By default, which is "No," all Pro Variables will be parsed quite late in the parsing order (i.e. when Global Variables are parsed). If set to Yes at all, then you can control the parsing timing of each individual Pro Variable. If set to "Yes, before Snippets," early parsing will happen just before existing Template Partials and config variables are parsed, which means they can include Partials. If set to "Yes, after Snippets," that means EE will parse (chosen) Pro Variables just after Template Partials and variables set in config.php, so you can include Pro Variables in those places.
25+
26+
NOTE: You also need to turn on early parsing for each individual variable you want to exhibit this behavior.
2527

2628
WARN: Use caution when turning on this feature, as users could potentially break your templates!
2729

2830

2931
### Variable types
3032

31-
Here you can find a list of available Variable Types and Pro Variables compatible Field Types. Select which types you want to enable. Disabled types will not appear in the module.
33+
Here you can find a list of available Variable Types Pro Variables-compatible Field Types. Select which types you want to enable. Disabled types will not be made available in the module.

docs/add-ons/pro-variables/tags.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In most cases, the simple global variable syntax, eg. `{my_var}` will do. Global
1717

1818
{exp:pro_variables:parse var="my_var"}
1919

20-
Use the Parse, Single or Pair tag to parse variables during the Module & Plugin stage. You can also use parameters, which will allow for more options than just using the variable syntax. Some variable types, like RTE and Grid, require using the tag syntax to trigger additional processing.
20+
Use the Parse, Single or Pair tags to parse variables during the Module & Plugin stage of template parsing. Parse can be used as either a single or a pair tag - but that can sometimes confuse the EE parser if it's in use both ways in a template. Like all `exp:` tags, these can be assigned parameters, which will allow for more options than just using the variable syntax. Some variable types, like File, RTE and Grid, require using the tag syntax to trigger additional processing.
2121

2222
TIP: TIP: **{ee:u}** Learn more about the parsing stages at [ExpressionEngine University](https://u.expressionengine.com/course/ee-conf-spring-summit-2021/eeconf-spring-2021-but-first-parse-order-and-php-in-expressionengines-templates).
2323

@@ -27,7 +27,7 @@ NOTE: **Note:** Whenever you need parameters or additional processing, use the *
2727

2828
#### `var`
2929

30-
Name of the variable you want to parse. Use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, eg. `my_site:my_var`. If this parameter is omitted, all Pro Variables inside the tag pair are simply replaced with their values.
30+
Name of the variable you want to parse. If you're using multi-site manager, use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, e.g. `my_site:my_var`. If the var parameter is omitted (it is optional with a tag pair), all Pro Variables inside the tag pair are replaced with their values.
3131

3232
#### `multiple`
3333

@@ -37,38 +37,47 @@ If set to `yes`, the tag will loop through the different values of the variable.
3737

3838
Use in combination with `multiple="yes"` to limit the number of results displayed.
3939

40-
4140
#### _3rd party_
4241

4342
If you’re displaying a 3rd party field type, you can use all parameters you would normally use for the field channel variable pair.
4443

45-
### Variables
44+
### Variable Options
45+
46+
NOTE: **Note:** Some of these `{my_var:…}` variable options are available _only_ when using the Parse tag pair or Pair tag pair, _and_ if the variable type allows multiple items to be selected. For more options on the native variable types, [check their properties](/add-ons/pro-variables/type.md).
4647

47-
#### `{_my_var_:data}`
48+
#### `{my_var:data}`
4849

4950
The variable value.
5051

51-
#### `{_my_var_:data_label}`
52+
#### `{my_var:data_label}`
5253

5354
The variable value’s label, when displaying a Checkbox Group, Radio Group or Select variable type.
5455

55-
#### `{_my_var_:label}`
56+
#### `{my_var:label}`
5657

5758
The variable label, as displayed in the Control Panel.
5859

59-
#### `{_my_var_:count}`
60+
#### `{my_var:count}`
6061

6162
Current count of the loop.
6263

63-
#### `{_my_var_:total_results}`
64+
#### `{my_var:total_results}`
6465

6566
Total of iterations of the loop.
6667

6768
#### _3rd party_
6869

6970
If you’re displaying a 3rd party field type, you can use all variables you would normally use inside the field channel variable pair.
7071

71-
NOTE: **Note:** the `{_my_var_:…}` variables are _only_ available when using the Parse tag pair or Pair tag pair, _and_ if the variable type allows multiple items to be selected. For more options on the native variable types, [check their properties](/add-ons/pro-variables/type.md).
72+
### Variable Modifiers
73+
74+
You can use [variable modifiers](templates/variable-modifiers.md) on Pro Variables when using them in a tag pair.
75+
76+
{exp:pro_variables:parse}
77+
Encrypted text var: {my_text:encrypt}
78+
{/exp:pro_variables:parse}
79+
80+
### Code Examples
7281

7382
{exp:pro_variables:parse var="my_site:my_var"}
7483

@@ -97,15 +106,15 @@ In order to avoid conflicts with multiple instances of the Parse tag, both singl
97106

98107
## Pair tag
99108

100-
{exp:pro_variables:pair var="my_var"}{/exp:pro_variables:pair}
109+
{exp:pro_variables:pair var="my_var"}{my_var:data}{/exp:pro_variables:pair}
101110

102111
In order to avoid conflicts with multiple instances of the Parse tag, both single and paired, you can use the alias `{exp:pro_variables:pair}` for tag pair use. It is identical to the Parse tag, but meant for tag pair use only.
103112

104-
You can also use [variable modifiers](templates/variable-modifiers.md) on pro variables when using them in a tag pair:
113+
You can also use [variable modifiers](templates/variable-modifiers.md) on Pro Variables when using them in a tag pair:
105114

106-
{exp:pro_variables:parse}
115+
{exp:pro_variables:pair var="my_text"}
107116
Encrypted text var: {my_text:encrypt}
108-
{/exp:pro_variables:parse}
117+
{/exp:pro_variables:pair}
109118

110119
## Label tag
111120

@@ -117,29 +126,33 @@ You can display the label of any variable by using this tag. Use as single tag o
117126

118127
#### `var`
119128

120-
Name of the variable you want to fetch the label from. Use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, eg. `my_site:my_var`. _This is a required parameter_.
129+
Name of the variable you want to fetch the label from. Use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, e.g. `my_site:my_var`. _This is a required parameter_.
121130

122131
## Options tag
123132

133+
{exp:pro_variables:options var="my_site:my_multi_var"}
134+
<label><input type="checkbox" value="{my_multi_var:data}" {checked} /> {my_multi_var:data_label}</label>
135+
{/exp:pro_variables:options}
136+
124137
This tag pair allows you to display the options for a given variable. Use this in combination with the **Checkbox Group**, **Radio Group** and **Select** variable types.
125138

126139
### Parameters
127140

128141
#### `var`
129142

130-
Name of the variable you want to parse. Use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, eg. `my_site:my_var`. _This is a required parameter_.
143+
Name of the variable you want to parse e.g. `var="my_var"` . Use a colon to separate site name and variable name if you want to parse a variable belonging to a specific site, eg. `my_site:my_var`. _This is a required parameter_.
131144

132-
### Variables
145+
### Variables and Variable Options
133146

134-
#### `{_my_var_:data}`
147+
#### `{my_var:data}`
135148

136149
Value of the option.
137150

138-
#### `{_my_var_:data_label}`
151+
#### `{my_var:data_label}`
139152

140153
Associated label of the value.
141154

142-
#### `{_my_var_:label}`
155+
#### `{my_var:label}`
143156

144157
Label of the variable itself.
145158

@@ -161,7 +174,9 @@ The total amount of options.
161174

162175
#### `{count}`
163176

164-
The count out of the current option.
177+
The count of the current option.
178+
179+
### Code Examples
165180

166181
{exp:pro_variables:options var="my_multi_var"}
167182
{if count == 1}<ul>{/if}

docs/add-ons/pro-variables/type.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Character to separate multiple values. Either a new line (`\n`), a pipe (`|`) or
4242

4343
Displays a date picker. To output anything other than a timestamp, use the `{exp:pro_variables:single}` tag. This takes the same parameters as the native Date field. Additionally, use `modifier="relative"` to output a relative date string.
4444

45-
### Code examples
45+
### Code example
4646

47-
{exp:pro_variables:single var="my_var" format="%Y-%m-%d"}
47+
{exp:pro_variables:single var="my_date_var" format="%Y-%m-%d"}
4848

49-
{exp:pro_variables:single var="my_var" modifier="relative"}
49+
{exp:pro_variables:single var="my_date_var" modifier="relative"}
5050

5151
## File
5252

@@ -58,6 +58,16 @@ Uses the native [File field](/fieldtypes/file.md). To output the variable, alway
5858

5959
Allows applying modifiers, which, among other, are used to apply [on-the-fly image manipulations](/fieldtypes/file.md#on-the-fly-image-manipulations) to files
6060

61+
### Code example
62+
63+
{exp:pro_variables:pair var="my_file_var"}
64+
<figure>
65+
<img src="{my_file_var:image}">
66+
<figcaption>Photo by {my_file_var:credit}</figcaption>
67+
</figure>
68+
{my_file_var:description}
69+
{/exp:pro_variables:pair}
70+
6171
## Grid
6272

6373
Uses the native [Grid field](/fieldtypes/grid.md). All native types are available, _except for Relationships and Members_. To output the variable, use the `{exp:pro_variables:pair}` or `{exp:pro_variables:single}` tag where appropriate. You can use any of Grid’s [parameters](/fieldtypes/grid.md#parameters) and [variables](/fieldtypes/grid.md#variables) using these tags. Additionally, one more parameter is available:
@@ -68,17 +78,9 @@ Uses the native [Grid field](/fieldtypes/grid.md). All native types are availabl
6878

6979
Any of the available [modifiers](/fieldtypes/grid.md#modifiers), which will trigger the output the modifier provides.
7080

71-
### Code examples
81+
### Code example
7282

73-
{exp:pro_variables:pair var="my_var"}
74-
<figure>
75-
<img src="{my_var:image}">
76-
<figcaption>Photo by {my_var:credit}</figcaption>
77-
</figure>
78-
{my_var:description}
79-
{/exp:pro_variables:pair}
80-
81-
{exp:pro_variables:single var="my_var" modifier="total_rows"}
83+
{exp:pro_variables:single var="my_grid_var" modifier="total_rows"}
8284

8385
## Radio Group
8486

@@ -257,10 +259,11 @@ The short name of the Image Manipulation you want to output. Alternatively, you
257259

258260
### Code examples
259261

260-
{exp:pro_variables:single var="pv_files_var" manipulation="squared"}
262+
{exp:pro_variables:single var="my_files_var" manipulation="squared"}
263+
264+
{exp:pro_variables:pair var="my_files_var"}
265+
<img src="{my_files_var:squared}" alt="">
261266

262-
{exp:pro_variables:pair var="pv_files_var"}
263-
<img src="{pv_files_var:squared}" alt="">
264267
{/exp:pro_variables:pair}
265268

266269
## Table
@@ -292,13 +295,15 @@ Limit the number of rows displayed.
292295

293296
### Code examples
294297

295-
{exp:pro_variables:pair var="pv_table_var"}
298+
{exp:pro_variables:pair var="my_table_var"}
299+
296300
{if count == 1}<ul>{/if}
297301
<li><a href="{cell_1}">{cell_2}</a></li>
298302
{if count == total_results}</ul>{/if}
299303
{/exp:pro_variables:pair}
300304

301-
{exp:pro_variables:pair var="pv_table_var" sort="random" limit="1"}
305+
306+
{exp:pro_variables:pair var="my_table_var" sort="random" limit="1"}
302307
Random link: <a href="{cell_1}">{cell_2}</a>
303308
{/exp:pro_variables:pair}
304309

@@ -356,14 +361,16 @@ To be used in combination with `format`. Possible values: `none`, `safe` or `all
356361

357362
#### `preparse:_my_var_`
358363

359-
If the variable content contains variables that need to be parsed before it is put in the template, you can use this parameter, similar to [embed variables](/templates/embedding.md#embedding-variables). For example: setting the parameter `preparse:foo="bar"` will replace the variable `{preparse:foo}` with `bar` in the variable content.
364+
If the variable content itself contains variables that ought to be parsed before the Pro Variable is put in the template, you can use this parameter. It's similar to [embed variables](/templates/embedding.md#embedding-variables). For example: setting the parameter `preparse:foo="bar"` will replace `{preparse:foo}` with `bar` in the variable content.
360365

361366
#### `preparse_prefix`
362367

363-
See above, change the default variable prefix from `preparse` to something else. For example, the parameters `preparse:foo="bar" preparse_prefix="pv"` will replace the variable `{pv:foo}` with `bar` inside the variable content.
368+
Used with pre-parsing, this changes the default variable prefix from `preparse` to something else. For example, the parameters `preparse_prefix="pv" preparse:foo="bar"` will replace `{pv:foo}` with `bar` inside the variable content.
364369

365370
### Code examples
366371

367372
{exp:pro_variables:single var="my_var" formatting="xhtml" html="all"}
368373

369-
{exp:pro_variables:single var="my_var" preparse:entry_id="12"}
374+
{!-- for a variable that has {pv:entry_id} and {pv:cat_id} in its content --}
375+
{exp:pro_variables:single var="my_var" preparse:entry_id="12" preparse:cat_id="9" preparse_prefix="pv"}
376+

0 commit comments

Comments
 (0)