Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How inject create date in confluence page title?

Tony Montana
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 13, 2015
 

5 answers

1 accepted

2 votes
Answer accepted
Christian Czaia _Decadis AG_
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 14, 2015

Have a look here: https://answers.atlassian.com/questions/332522

You'd have to create a blueprint

7 votes
Davin Studer
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 14, 2015

You could create a template(blank or not) and then use the "create from template" macro. In the macro options for the title put @currentDate. See the below screen capture.

image2015-1-14 15_43_36.png

SABVARX June 17, 2017

Thank you David for sharing this solution. It works well for us!

Mike McNamara August 14, 2018

I agree, this is better than the accepted solution mentioned which gets into programming and macros.

A template, a page with a Create from Template Macro, and your all set. If you include tags on your template, you can build a children display, essentially like the Meeting Notes page you get on a new space.

Nikki Anderson November 6, 2019

Hi Davin (or anyone who might be able to help).

I have created this macro on a page using the @currentDate feature and it works, but it places the newly created page at the bottom of the list of past pages (also with their current/created dates as titles). It seems the only way to sort is alphabetically and when I toggle the option it puts all the pages in oldest date first to newest last.

How do I get it to default to the top of the list?

Kirstin Seidel-Gebert
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.
November 6, 2019

IMHO there is no way to achieve this in an automated way. Correct me if I'm wrong.

Nikki Anderson November 6, 2019

Yeah, no automated way, but I did find this thread from 2016 and am trying it. So far, I put in the code into the Look and Feel--> Stylesheet, but it didn't work, so perhaps I captured the wrong child id number. Trying again...

Kirstin Seidel-Gebert
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.
November 6, 2019

Ah, that sounds interesting but could possibly break something else in the page tree.
Nevertheless, worth a try.

I think it is not about capturing the right child ID number but the right HTML element resp. CSS class to apply this styling to. This depends on your Confluence version and if you have any plugins installed that are affecting the page tree.

Nikki Anderson November 6, 2019

Well, it seems to work! I had left out the last number of the child ID. Now it works! I keep creating new child pages with future dates as the page title/name, and they automatically are put at the top of the list exactly how I wanted. And nothing else so far seems to be messed up from it. While this should be an easy button feature, I'm happy with myself for researching and applying this. :-)

1 vote
Robb Chen-Ware August 30, 2019

This doesn't seem to be compatible with the new editor in my testing. Anyone else seeing different results?

kpink September 10, 2019

Yes, labels and the page nam are no longer defaulting.  I wish we could use the old editor until they fix all the annoying issues with the new one

0 votes
Shanta Nathwani June 21, 2019

This is close to what I was looking for. I want to populate the title with a specific title, that the user can add to at the time of creation. Right now, when a user creates my template, the title goes blank. I want to be able to generate something like: "Client Page: X", where the user can fill in X with the name of the client.

Kirstin Seidel-Gebert
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.
June 23, 2019

Hi Shanta,

I once also had a similar requirement and implemented a user macro that can be inserted as a button to a page.
Clicking on this button will create a new page below the page that contains the button and will set a specific page title and specific labels that are given with the macro.

If you are interested, I can post the macro code.

Cheers,
Kirstin

Like Petter Topp likes this
Shanta Nathwani June 24, 2019

I've been able to accomplish that in other areas, especially with the date, but in this case, it's based on a template in new spaces that we create for a new client. I'm actually working on a way to create an entire space template, so the only "button" I really want is "Create this space" and have it create the relevant pages, templates and titles. For the case I posted here, I have no where to put the button.

Kirstin Seidel-Gebert
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.
June 24, 2019

Ah, OK. This is something different from what I did. IMHO you will end up with coding (blueprint/plugin).

Shanta Nathwani June 25, 2019

I was headed in that direction anyway. Thanks for the help!

Petter Topp March 27, 2020

Hello Kristin.

I'm a Confluence newbie and are looking to achieve exactly what you solved.

Would be very grateful if You could help me with this.

Kirstin Seidel-Gebert
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.
April 1, 2020

Hello Petter,

my macro handles dates and labels. It generates a blogpost title like <label> - Statusreport Woche 14/2020.

## Macro title: SA Blog Post Button
## Macro has a body: No
## Body processing: No macro body
##
## Developed by: Kirstin Seidel-Gebert
## Date created: 22.03.2013
## Installed by: Kirstin Seidel-Gebert
## 19.02.2014 KGE Initialize the blog post title with a combination of
## - customer name (taken from the confluence page title, the macro is embedded in)
## - week and year of the current date
## 11.03.2014 KGE Remove "system" labels from list of labels
## Atlassian uses the labels for managing the favorites of users. Labels starting with "~" or "my:" are system labels.
## Only add &labelsstring to the URL, if it isn't empty.


## @param Pl:title=Label with page labels|type=boolean|desc=If checked, the blog post automatically gets labeled with all labels of the page the macro was added to.|required=true
## @param Labels:title=Labels|type=string|desc=Enter the additional labels for this new blog post as a comma separated list.|required=false
## @param LinkText:title=Link/Button Text|Level|type=string|desc=Enter the text of the link/button.|required=true

## Get the base URL of Confluence.
#set( $wikibaseurl = "${req.getContextPath()}" )

## Check whether the blog post should be automatically labeled.
#set( $pageLabels = [] )
#set( $pageLabels = $content.getLabels() )

## Add the additional labels.
## --------------------------
#set ( $addLabelsString = "" )
#if ( $paramLabels )
#set ( $addLabelsString = $paramLabels )
#end

#if ( $pageLabels && $paramPl )
#foreach ($label in $pageLabels)
#set ( $lstr = $label.toString() )

#if ( $lstr.substring(0,1) != "~" && $lstr.substring(0,3) != "my:" )

## Add comma before adding an additional label (not if empty)
#if ( $addLabelsString != "" )
#set ( $addLabelsString = $addLabelsString + ", " )
#end

## Append Label
#set ( $addLabelsString = $addLabelsString + $label )
#end
#end
#end

## Construct the blog post title.
## ------------------------------

## First get year and week.
#set ( $currentDate = $content.currentDate )
#set ( $year = ${action.dateFormatter.formatGivenString("yyyy", $currentDate)} )
#set ( $week = ${action.dateFormatter.formatGivenString("ww", $currentDate)} )

## Next get the customer name from the page title.
## Initialize $blogTitle
#set ( $blogTitle="<Kundenname> - " )

## Get the page title and split it into words.
#set ( $pageTitle = $content.getTitle() )
#set ( $titleArray = $pageTitle.split(" ") )

## Convert the array of words into a list that can be handled by velocity.
#set ( $titleList = [] )
#foreach ($element in $titleArray)
#set ( $dummy = $titleList.add($element) )
#end

#set ( $blogTitle = $titleList.get(0) + " - Statusreport Woche " + $week + "/" + $year )
## debug <p>$pageTitle</p>

## Insert the button/link.
## -----------------------
<span class="e2e-button">
#if ( $addLabelsString != "" )
<a href='$wikibaseurl/pages/createblogpost.action?spaceKey=$space.key&title=$blogTitle&labelsString=${addLabelsString}'>$paramLinkText</a>
#else
<a href='$wikibaseurl/pages/createblogpost.action?spaceKey=$space.key&title=$blogTitle'>$paramLinkText</a>
#end
</span>

The part relating to the date is the following:

## First get year and week.
#set ( $currentDate = $content.currentDate )
#set ( $year = ${action.dateFormatter.formatGivenString("yyyy", $currentDate)} )
#set ( $week = ${action.dateFormatter.formatGivenString("ww", $currentDate)} )

[...]

#set ( $blogTitle = $titleList.get(0) + " - Statusreport Woche " + $week + "/" + $year )

Hope that helps.
Cheers,
Kirstin

Like Davin Studer likes this
Petter Topp April 1, 2020

Thank You very much Kristin I will have a look at it.

Br

Petter

Davin Studer
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.
April 1, 2020

@Kirstin Seidel-Gebert Love the user macro! Great idea.

Kirstin Seidel-Gebert
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.
April 1, 2020

Thanks, Davin. :)

0 votes
EPS Software Engineering AG
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.
June 11, 2016

Hi,

Our Add-on provides default tags like __Current_date__, etc. They can be used within the page title and anywhere on the page; also in macro parameters.

Try our Live Examples (no registration needed).

Marketplace link: Page Tree Creator.

Regards,
Stephan

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events