Published on
You can use Chronoforms shortcodes to retrieve form or system info, or generate some data like UUIDs, here is a list of supported shortcodes in Chronoforms v8:
- {var:var_name} will retrieve a variable named var_name, variables are set by actions usually, or set using PHP code you have used.
- {const:null} will return a null value
- {data:param} will return the value of a request/get/post parameter named "param", you may pass a default value too: {data:param default-value}
- {post:field-name} will return the value of the field from $_POST, this is useful if you want the latest fresh posted field value
- {session:param} will get the stored session variable named "param"
- {user:id}, {user:username}, {user:name}, {user:email} will return the user's id, username, name, email address
- {data:}, {date:date-format} will return the server date now in mysql format Y-m-d H:i:s or according to the format specificed
- {icon:icon-name} will return an SVG fontawesome icon code
- {l-language-string} will return a translated language string defined in the form's locales
- {fn:action-name} or {action:action-name} will run a form function by name
- {vw:view-name} or {view:view-name} will run a form view by name
- {url:} will return the current url
- {path:front} will return the path to the Chronoforms frontend folder where the uploads folder exist
- {path:admin} will return the path to the Chronoforms admin folder
- {path:root} will return the path to the CMS root
- {str:uuid} will return a UUID string
- {str:ip} will return the client's ip address
- {str:rand} will return a random number using mt_rand
- {globals:var-name} will return the value of a global variable defined in the ChronoForms8 settings page
- {fields:completed} can be used in HTML views to generate a list of completed form fields and their values, similar to the one generated in the Email body.
Additionally, you may add few functions to the shortcode to change the value returned by the shortcode:
- {data.quote:field} will quote the field value for database operations, this is useful to prevent SQL injections
- {data.encode:array-field} to return a json encoded value of the field, useful when the field value is an array like a checkboxes group or a multi value dropdown
- {data.join:array-field} to return a joined list of an array like a checkboxes group or a multi value dropdown
Comments: