Which variables can I use in the "Custom Display" field?

Last modified by Thomas Mortagne on 2017/02/03

In a doc Class, properties have "Custom Display" field , to display data in a ... custom way, like User Property Custom Display by example.
User Property Custom Display

Here some velocity script you can use in this field. The core make available the following variables:

  • $name = the name of the displayed field
  • $prefix = a prefix for the form field
  • $object = the displayed object
  • $type = the intended display mode (view, edit, hidden, search...)
  • $value = the property value
  • $field = the definition of the property (in the class)

So, in a custom Page type property (or database list), if you want:

  • in edit mode a select list to choose a page or nothing
  • in view mode a link to the page chosen page (or nothing)

Here a "Custom Display" field:

#if ($type == 'edit')
 #set ($MySelectList="<select id='" + "${prefix}${name}" + "' size='1' name='" + $prefix + ${name} + "'>")
 #set ($Selected="")
 #if ($!value=='')
   #set ($Selected=" selected='selected'")
 #set ($MySelectList=$MySelectList + "<option value=''" + $!Selected + " label='" + $services.localization.render('Space.DocWith_XWiki.TranslationDocumentClass_Object.Empty') + "'>" + $services.localization.render('Space.DocWith_XWiki.TranslationDocumentClass_Object.Empty') + "</option>")
 #foreach($listitem in $list)
   #if ($listitem==$value)
     #set ($Selected=" selected='selected'")
     #set ($Selected="")
   #set ($MySelectList=$MySelectList + "<option value='" + $listitem + "'" + $!Selected + " label='" + $listitem + "'>" + $listitem + "</option>")
 #set ($MySelectList=$MySelectList  + "</select>")
 #set ($MySelectList=$MySelectList  + "<input type='hidden' value='' name='" + ${prefix} + ${name} +"'>")
 {{html clean=false}}
#elseif (($type == 'view') && ($!value!=''))

Of course, you can use a similar code in the Sheet to display data like you want.

Created by Pascal Bastien on 2015/04/20

Get Connected