XWiki HowTo’s

Version 2.1 by Roman Friesen on 2009/09/15 11:54

XWiki HowTo's

  1. Links
  2. Velocity Macros
    1. Some Velocity queries
    2. Create Velocity Macro

Velocity Macros

Some Velocity queries

  • Admin rights
    #if ($xwiki.hasAdminRights())
      The current user has admin rights
    #end
  • Edit rights
    #if($hasEdit)
      The current user has edit rights
    #end
  • Language
    #if ($context.language == "de")
      German translation is required
    #elseif ($context.language == "fr")
      French translation is required
    #else
      THE LANGUAGE "$context.language" IS NOT SUPPORTED.
    #end

Create Velocity Macro

A write access to your XWiki installation directory is required!

  1. Add a new macro to the file "macros.vm"
    • see "<xwiki-installation-root>/xwiki/templates"
    • add at the end of the file your new macro, for example:
      #macro(myMacroName)
      Hello World!
      #end
  2. Register the new macro in the file "macros.txt"
    • see "<xwiki-installation-root>/xwiki/templates"
    • add at the end of the file the line, for example:
      myMacroName=velocity:myMacroName:
  3. After XWiki restart the new velocity macro can be used in a common way: either using the WYSIWYG editor or text mode.