Hey guys,

I would like to split the "Created and last modified by" into parts.

The goal is to have both the creation-date aswell as "last-modified".

Is it possible for pages and blog-entries?

2 answers

1 accepted

Hi Tim,

Pages and BlogPosts inherit everything from AbstractPage which includes getCreator(), getCreationDate(), getLastModifier() and getLastModificationDate().

What do you want to do exactly, maybe I can help?

Regards

Theresa

Hi Theresa,

it would be perfect if where the "Created and last modified by [...] about 2 hours ago" appears, confluence would show the CreationDate AND next to it the LastModificationDate.

How can I implement it?

Thanks for the answer!

It resolves to something like the following unreadable lines:

#set($page = $blog)
    #if ($page.isNew())
        #set ($dateLink = "$!req.contextPath/pages/viewpreviousversions.action?pageId=$page.id")
    #else
        #set ($dateLink = "$!req.contextPath/pages/diffpagesbyversion.action?pageId=$page.id&selectedPageVersions=$page.previousVersion&selectedPageVersions=$page.version")
    #end

    #* Note: bunched up else statements are intentional, otherwise we get whitespace that messes up formatting ;) *#
    #if (!$renderStatic)
        #set ($authorWithHtml = "#if($page.creatorName) #userLink($page.creator)#else $i18n.getText('anonymous.name')#end")
        #set ($editorWithHtml = "#if($page.lastModifierName) #userLink($page.lastModifier)#else $i18n.getText('anonymous.name')#end")
    #else
        #set ($authorWithHtml = "#if($page.creatorName) $page.creatorName#else $i18n.getText('anonymous.name')#end")
        #set ($editorWithHtml = "#if($page.lastModifierName) $page.lastModifierName#else $i18n.getText('anonymous.name')#end")
    #end

    #set ($authorWithHtml = "<span class='author'>$authorWithHtml</span>")
    #set ($editorWithHtml = "<span class='editor'>$editorWithHtml</span>")

Without writing a plugin, you could edit the page decorators.

For the blog post page:

  • Administration Console
  • Look and Feel > Layouts
  • Select "Create custom" for Blog Post Layout

You'll find a line like

#parse ("/decorators/includes/page-metadata.vm")

... and ...

#if ($generalUtil.isDateWithin24Hours($page.lastModificationDate) && !$renderStatic)
        #set ($i18nSuffix = ".ago")
        #set ($modifiedDate = $friendlyDateFormatterHelper.format($page.lastModificationDate))
    #else
        #set ($i18nSuffix = ".on")
        #set ($modifiedDate = $dateFormatter.format( $page.lastModificationDate ))
    #end

    #if (!$renderStatic)
        #set ($modifiedDate = "<a class='last-modified' title='$dateFormatter.formatDateTime( $page.lastModificationDate )' href='$dateLink'>$modifiedDate</a>")
    #end

    #if ($page.isNew())
        $i18n.getText("created.by$i18nSuffix", [$authorWithHtml, $modifiedDate])
    #else
        #if ($page.creator == $page.lastModifier)
            $i18n.getText("created.and.modified.by$i18nSuffix", [$authorWithHtml, $modifiedDate])
        #else
            $i18n.getText("created.by.modified.by$i18nSuffix", [$authorWithHtml, $editorWithHtml, $modifiedDate])
        #end
    #end

You can replace the original velocity macro and edit it. The last few lines handle the actual text to display and can easily be edited.

BUT: You should be aware that this is (or should be) resetted after updating Confluence, since this markup may change, too.

Hope I could help

Theresa

Thank you, this was exactly what I was looking for.

Have a nice weekend!

Hi Theresa,

it would be perfect if where the "Created and last modified by [...] about 2 hours ago" appears, confluence would show the CreationDate AND next to it the LastModificationDate.

How can I implement it?

Thanks for the answer!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

304 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you