User Tools

Site Tools


Sidebar

Dokumentation

vortex:scripting:vxstring

Vortex String

The Vortex String, or VxString for short, is a string which uses a custom syntax for variable substituion in the Vortex. The syntax and substitution rules are described below.

Syntax

The VxString is parsed by the Vortex using a regular expression, from left to right. Variable names enclosed by []-brackets are substituted by their respective variable/field relative to the current Table or TableRecord. Functions or class methods enclosed by {}-brackets are substituted by the return value from the corresponding call. Parameters are concatenated by appending a .-separated list after the function/method name, and variables can be used by enclosing them in []-brackets.

Example:

  This is the id of this post: [idpost]
  This is the name of some related post: [relatedpost.name]
 
  Running a Vortex-internal function getting the date: {date}
  Getting the date a week from now: {date.w+1}
  Running a php function: {abs.-1}
  Running some method from some class with parameters "a", "b" and name from the current tablerecord/table: {class:method.a.b.[name]}
  Running a method in this current Tablemethods script with the same parameters: {method.a.b.[name]}

Functions are identified in the following order:

1. Internal vortex functions
2. Class:Method methods
3. Internal PHP functions
4. Methods in the Tables Methods-class.

Vortex internal functions

Currently the following functions are implemented locally in the Vortex:

modify

Using an older syntax, used to modify strings.

 {modify.string|left:3}

Will take the leftmost 3 characters of string..

The supported modifiers are left, right, mid, where mid takes two arguments separated by : like:

 {modify.string|mid:1:2}

Where the first argunent is from and the last is to. The given syntax above would return tr.

date

Returns the date on the format YYYY-mm-dd. Otherwise similar to time.

time

Returns the datetime on the format YYYY-mm-dd HH:ii:ss as given by the PHP date function.
The timestamp can be modified by giving arguments like

 {time.d+1.Y=2010}

This will return the datetime for tomorrow but the year will be set to 2010.

Currently the following modifiers are supported with a +, - or = sign and a value, telling the Vortex to add, subtract or set the period.

ModifierPeriod
sSecond
iMinute
HHour
dDay
wWeek
mMonth
YYear

As of build 1167 the time and date functions also take a format argument on the form of the PHP date format string.

  {time.format=Y/m.m+2}

The code above returns the year and month, two months from the current date, separated by a slash.

user

Returns an attribute from the currently active user. Supplying no parameters will return the UUID for the active user, otherwise it will return the given attribute. Related attributes can be used providing the current user has sufficient privilegies to read them.

vortex/scripting/vxstring.txt · Last modified: 2019/06/28 06:56 by hubbe