Note: This is a deprecated function, largely superseded by [%if%]
and simply the [@tag@]
tags.
Data
Neto by Maropost's legacy tag for writing conditionals and calculations.
Example
[%set [@test@] %]2[%/set%]
[%data id:'test'%]
[%param case_1%]1[%/param%]
[%param case_1_value%] one[%/param%]
[%param case_2%]2[%/param%]
[%param case_2_value%] two[%/param%]
[%param case_3%]3[%/param%]
[%param case_3_value%] three[%/param%]
[%param case_default_value%] default fallback[%/param%]
[%/data%]
Usage
Dynamically Referencing Tags
Data encapsulated within the [%data%]
function can be referenced dynamically.
[%forloop from:'1' to:'40' %]
[%param *body%]
[%data id:'misc[@count@]'%]
[%param case_1%]misc33[%/param%]
[%param case_1_value%] Display content[%/param%]
[%/data%]
[%/param%]
[%/forloop%]
Calc Function
[%data%]
can also be used as a calc function.
[%data id:'count' calc:'%' cvalue:'2' if:'=' value:'0'%]
[%param *if_true%] ... [%/param%]
[%param *if_false%] ... [%/param%]
[%/data%]
If Statement
The [%data%]
function can also be used as an if statement. In this example, the [@discount_total@]
will only display if it is greater than zero:
[%data id:'discount_total' if:'>' value:'0' %]
<p>Discount Total: [@discount_total@]</p>
[%/data%]
Parameters
Name | Options | Description |
---|---|---|
`id:''` | String | Sets the ID for the data so it can be referenced/targeted elsewhere. Can also be used as the name of the variable in calculations |
`if:''` | `eq`, `ne`, `=`, `==`, `!=`, `>`, `<` | The initial condition of the tag |
`calc:''` | `*`, `/`, `+`, `%`, `**`, `( )` | Calc function for performing arithmetic within the conditional. Accepts [calc function](https://developers.neto.com.au/documentation/neto-designer-documentation/b-se-tag-library/function-tags/logic-and-calculation/calc/) parameters |
`value:''` | Number or variable | Value to compare against the variable |
`cvalue:''` | Number | Used to specify return order for calc function results. Succeeds the value of the variable specified by `id:''` |
`fvalue:''` | Number | Used to specify return order for calc function results. Precedes the value of the variable specified by `id:''` |
`*if_true` | HTML & b@se tags | Return value for code that complies with the initial condition of the tag |
`*if_false` | HTML & b@se tags | Return value for code that does not comply with the initial condition of the tag |
`*case_#` | HTML & b@se tags | Designation for cases to be included in the tag. Replace `#` with a value from 1 to 999 |
`*case_#_value` | HTML & b@se tags | Values of designated cases. Replace `#` with a value from 1 to 999 |