/>
Formatting and manipulating data

After you have requested data by means of dataname notation, you have plenty of options to format the data.

How to apply formatting or manipulations on your data

You can apply a format to your data by using the following format:

title@content|format:urlvar

After the dataname notation follows a vertical line: |. Then add the format that you want to apply to the data. Below an overview of the different formatting options:

 

Formatting options concerning text

format:nospaces

Can only be applied to text.

This option removes all spaces from the text value. So "this is a sentence" becomes "thisisasentence"

format:urlvar

Can only be applied to text.

This option converts the text to a text that can be used in a url. In the conversion:

  • All letters are converted to lowercase
  • Spaces and "special" characters are converted to a -
  • Any html tags that are present will be removed
  • Question marks and exclamation marks are removed
  • Every start of a new rule is converted to -

That means that "This can (not) be in a URL" "this-can--not--be-in-a-url". This formatting options is mostly relevant if you want to automate your SEO.

format:text

Can be applied to text, numbers and elements.

This option converts the specified data into readable text. So:

  • text simply remains text
  • numbers become text, so 123 becomes "123"
  • elements are converted to the readable name of the element

format:twoliner

Can be applied to text

This formatting option returns the first two sentences of the given text.

 

Layout options about booleans (true / false)

format:boolean

Can be applied to text, booleans and numbers

This option makes true or false of the specified value. The following data is converted to false:

  • NULL
  • ""
  • 0
  • false
  • "false"
  • "n"
  • "N"
  • "no"
  • "nee"

The following options are converted to true:

  • "y"
  • "Y"
  • "yes"
  • "YES"
  • "j"
  • "J"
  • "ja"
  • "JA"

All other values are converted to NULL.

 

Formatting options about elements

format:id

Can be applied to elements

Returns the ID of the element.

format:element

Can be applied to numbers and textsFormatting options about elements

If the value is a valid ID of an element, the value is converted to the element itself.

 

Formatting options regarding dates

format:readabledate

Can be applied to numbers

The input is seen as a timestamp. A readable date display is made of this, for example "Sunday, February 4 2018".

 

Formatting options regarding currencies

format:currency

Can be applied to numbers

The input is seen as an amount in cents. The values are converted to a readable view of this amount. The currency that is used the is currency of the website or the system within the dataname is applied. An example is this formatting option: 7689 is converted to "$ 76.89".

This option is mostly relevant when designing product pages for a webshop.

Formating options for images

See the page about formatting options for images.

 

Calculations

Math

Can be applied to numbers

With the math option you can perform calculations on the current value. Options are:

  • Addition: math: +100 adds 100 to the current value
  • Subtract: math: -100 subtracts 100 from the current value
  • Multiply: math: * 100 multiplies the current value by 100
  • Share: math: / 100 divides the current value by 100

 

List manipulations

filter

Can be applied to lists

With the filter option you can filter lists. The syntax is:

filter:dataname:operator:value

For example, when you want to filter a list of subscriptions finding anyone with the first name "John":

filter:firstname@person:=:"John"

count

Can be applied to lists

The count option gives you the number of elements in a list

first

Can be applied to lists

Returns the first element from the list

list_to_string

Can be applied to lists

Returns the list as text. With the second parameter you can specify which character or text should be used when merging the list. Some examples:

list_to_string:, gives "one,two,three"

list_to_string:" and " gives "one and two and three"

 

Conditions

Within datanames you can also return a specific value under certain conditions. More about this on the page about conditions in datanames.

 

Request other values

dataname

Not type specific

Somewhere allong formatting a dataname you suddenly need the value from another field. For example, you have had a form where you have asked for a person's name for a very long time. Later on you switched to two separate fields: first name and last name. The original full name field still exists. With the following dataname you can show the value from the original name field, but if it is empty you show the value from the surname field:

name@person|if_break:tekst_is_not:""|dataname:lastname@person

You can find more about the aborting formatting options under a certain condition on the page about conditions in datanames.

 

Contact us

Do you want to participate in the dataname project? Or do you want to implement datanames and looking for some help? Send us a message and we'll be teaming up!

Datanames are an essential part of the Webanizr project