Context: Formatting strings are used in a number of locations such as the bookings settings in order to control how information is displayed to a user.  This information is displayed as a 'string' of text. This is an additional useful approach for making sure that users only see the information they are meant to see such as in a booking block on a calendar or for providing additional information, such as in a drop down box, which might help the user when making a choice.  For the steps below we are going to use a simple context of adjusting what information is used in a booking block.


Suitable for: Admins


Example location where formatting strings can be used:

  1. Click on Admin and got to Booking Preferences
  2. Select bookings
  3. The fourth section down is 'Format for Bookings on the Calendar'
  4. You have three options for controlling the look of bookings on a calendar depending on the view
  5. Change the format from 'default format' to 'specify the format'
  6. This will now give you the options for formatting the string


Options for formatting strings:


To refer to a single property:


Place the property inside % marks for example %dateRange.start.time%


Provide additional formatting of the property:


Use a ? within the property name at the end to indicate that additional options will be used as further formatting for the property


Provide separators:


Although a formatting string obeys additional characters outside of a property value as raw html text it may be easier given the dynamic nature of data within Calpendo to use separators.


For example it may be possible to do the following:


%owner.givenName% %owner.otherName% %owner.familyName%


If all three data values were present in the database then this would appear as:


John Reginald Smith

However if a user did not provide an otherName value because of the spaces between the properties it would be displayed as:


John  Smith

The double space would be visually disconcerting.


Therefore we would use a separator.  First within the property at the end we would add an ? for extra formatting followed by a letter such as s which would be used to say 'substitute' followed by the character which would be used as the separator.


Therefore the following would insert a space before and after a property value.  However if the property value was empty it would not show anything at all.


%owner.givenName?s s %


The following would therefore insert the * symbol as separators


%owner.givenName?s*s*%


In certain situations you might want to use a property but you are uncertain as to whether it might hold data.  It may be useful therefore to specify an alternate property which could be used.


Type in something along the lines of the following and this will use Family name if given name is not used. Whatever is specified after the : will be used if the value of the property is null.  If you do not want to specify another property to be used if the first one is null use NA after the :


%owner.givenName?ss:%%owner.familyName?s s:%

Properties such as dateRange.start will have information inside them such as the specific time itself.  If you want to extract just the time from the property use ?time to pull that data out.  Take a look at the following:


%dateRange.start?time%-%dateRange.finish?time%


If you would like text to appear before and after a property you can use the ? flag to add text.  For example:


%project.projectCode?shellosthere%

Will add the words hello and there with no spaces before and after the field defined.


Therefore:


%project.name?s s:%

will print the project.name property with a space in front of it, and prints nothing if the value is null.


For more advanced styling use HTML such as below


<div style="height:100%; font-size:80%;">
<div class="custom-booking-body" style="background-color:%usedLigand.colour?ss:#FFFFFF%; height:100%;">
%usedLigand.name?ss:NoLigand%</br>
%dateRange.start?time%-%dateRange.finish?time%</br>
%visit?ss: %</br>
%description?ss: %</br>
</div>