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:

{{velocity}}
#if ($type == 'edit')
 #set($MyClass=$object.getxWikiClass())
 #set($list=$MyClass.get($name).getListValues())
 #set ($MySelectList="<select id='" + "${prefix}${name}" + "' size='1' name='" + $prefix + ${name} + "'>")
 #set ($Selected="")
 #if ($!value=='')
   #set ($Selected=" selected='selected'")
 #end
 #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'")
   #else
     #set ($Selected="")
   #end
   #set ($MySelectList=$MySelectList + "<option value='" + $listitem + "'" + $!Selected + " label='" + $listitem + "'>" + $listitem + "</option>")
 #end
 #set ($MySelectList=$MySelectList  + "</select>")
 #set ($MySelectList=$MySelectList  + "<input type='hidden' value='' name='" + ${prefix} + ${name} +"'>")
 {{html clean=false}}
  $MySelectList
 {{/html}}
#elseif (($type == 'view') && ($!value!=''))
  [[$value||rel="_blank"]]
#else
  $value
#end
{{/velocity}}
 

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