Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Blog dates

Tim Schmidt January 23, 2014

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

0 votes
Answer accepted
resah
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2014

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

Tim Schmidt January 23, 2014

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!

resah
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2014

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>")

resah
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2014

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")

resah
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2014

... 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

Tim Schmidt January 23, 2014

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

Have a nice weekend!

0 votes
Tim Schmidt January 23, 2014

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
TAGS
AUG Leaders

Atlassian Community Events