Published on 12/17/2020
Published by Pratik Takle
Explicitly create variables with specific datatypes in Awesome
Since in WordPress anything in the shortcode is treated as a string value, we have provided the ability to explicitly create variables with specific datatype within the Awesome Enterprise shortcodes.
We support the following four create functions:
- Number : – this will create number (float) variable
- String: – this will create string variable
- Integer: -this will create integer variable
Create number values – [num.create /]
1 2 |
[num.create main="30.9" set=template.num_var /] --- This will return template.num_var with float as datatype |
- Modify value to Float
1 |
m.to_num=yes |
Create str values – [str.create /]
1 2 |
[str.create main="this is str" set=template.str_var /] --- This will return template.str_var with string as datatype |
- Modify value to Float
1 |
m.to_str=yes |
Create int values – [int.create /]
1 2 |
[str.create main="30" set=template.int_var /] --- This will return template.int_var with integer as datatype |
- Modify value to integer
1 |
m.to_int=yes |
Examples
1 2 3 4 |
[num.create main="40.3" o.set=template.x.num_check /] [str.create main='this is string' o.set=template.x.str_check/] [int.create main="5.60" o.set=template.x.int_check /] [template.x.dump /] |
array(3)
[
“num_check” => float(40.3)
“str_check” => string(3) “this is string”
“int_check” => int(5)
]