How to change the "Last modified" label?

Last modified by Vincent Massol on 2024/04/05

In order to change the "Last modified label" which is usually displayed under the title of pages, you will need to override a template inside the skin.

We recommend that you don't edit the original skin (named Default XWiki Skin), to avoid your customization being inadvertently overwritten during a future XWiki upgrade. Instead, you could create a new skin by copying the default one.

  1. To do this, in the Administration menu >> Look & Feel >> Themes, click on the Customize button in the Skin section. Then, in the More actions menu (button with vertical ...), select Copy.
  2. Once the copy has been made, return to the Themes menu, select your copied version of the skin from the drop-down menu and click on the Save button.
  3. For customization, click on the Customize button and then on Edit this skin. Here you can change the name of the skin (i.e: Copy of Default Skin), and also here we'll override contentheader.vm
  4. As this is an override, we need to retrieve the original code and add our customization to it. Depending on the version of XWiki that you have, the original code may very. This guide was created by using the current LTS version of XWiki, 14.10.18 as a reference point. The documentation linked above will guide you on how to check your original code.
  5. Paste the following code inside the contentheader.vm Content field and press the "Save & View" button.
    <div class="row document-header">
      <div class="document-info col-xs-12 #if($displayContentMenu)col-md-7#end">
        ## ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
        ## Display UI Extensions before the title element
        ## ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
        #foreach ($uix in $services.uix.getExtensions('org.xwiki.platform.template.title.before'))
          $services.rendering.render($uix.execute(), 'xhtml/1.0')
        #end
        <div id="document-title"><h1>$titleToDisplay</h1></div>
        #if (!$doc.isNew())
          ## Note that this serialization step is mandatory and we cannot count on the UserReferenceConverter here
          ## because UserReference#toString does not rely on the serializer so it's not the expected format for
          ## XWiki#getUserName(String).
          #set ($authorName = $services.user.serialize($tdoc.authors.originalMetadataAuthor))
          <div class="xdocLastModification">
            #if (!$doc.isMostRecent())
              $services.localization.render(
                'core.document.modificationWithVersion',
                ["<a href='$tdoc.getURL('view', ""rev=$tdoc.version"")'>$tdoc.version</a>",
                $xwiki.getUserName($authorName),
                $xwiki.formatDate($tdoc.date)
              ])
            #else
    <div class='row'>
    <div class='col-xs-6'
    Last modified and approved by 
              $services.localization.render($xwiki.getUserName($authorName)) on
              $services.localization.render($xwiki.formatDate($tdoc.date))
    </div
    </div>
            #end
          </div>
        #end
      </div>
      #if($displayContentMenu)
        <div class="document-menu col-xs-12 col-md-5">
          #template("menus_content.vm")
        </div>
      #end
    </div>
    <hr/>
  6. This will make your header display "Last modified and approved by "authorName" on "tdoc.date". 

Get Connected