It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How inject create date in confluence page title?

 

5 answers

1 accepted

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

You'd have to create a blueprint

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

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

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.

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?

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

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

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.

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

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

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

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

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.

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

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.

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

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

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.

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

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

Br

Petter

Davin_Studer Community Leader Apr 01, 2020

@Kirstin_Seidel-Gebert Love the user macro! Great idea.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

283 views 9 7
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you