Blog dates
Asked by Tim Schmidt:

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?


Answers:
author: resah
body: Hi Tim,

Pages and BlogPosts inherit everything from [AbstractPage](https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/pages/AbstractPage.html) which includes getCreator(), getCreationDate(), getLastModifier() and getLastModificationDate().

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

Regards

Theresa

comments: author: Tim Schmidt
body: 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!


author: resah
body: 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&amp;selectedPageVersions=$page.previousVersion&amp;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 = "&lt;span class='author'&gt;$authorWithHtml&lt;/span&gt;")    #set ($editorWithHtml = "&lt;span class='editor'&gt;$editorWithHtml&lt;/span&gt;")
```


author: resah
body: 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")
```


author: resah
body: ... and ...

```
#if ($generalUtil.isDateWithin24Hours($page.lastModificationDate) &amp;&amp; !$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 = "&lt;a class='last-modified' title='$dateFormatter.formatDateTime( $page.lastModificationDate )' href='$dateLink'&gt;$modifiedDate&lt;/a&gt;")    #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


author: Tim Schmidt
body: Thank you, this was exactly what I was looking for.

Have a nice weekend!


author: Tim Schmidt
body: 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!  


Tags: cloud

confluence-cloud