create Template that creates unique Page ID
Asked by Eijaz Sheikh:

Hi,

Is there a way to create a Page with a unique Page title e.g. "Project: " \& 10001? For every new page this number will increment.

I am currently a Space Administrator for a single space that i have created. But I am unable to create User macros. There does not seem to be any option. I can only add the built-in HTML macro.

Can anyone help quickly?


Answers:
author: EPS Software Engineering AG
body: Hi Eijaz,

You could use the App Page Tree Creator. It supports consecutive numbers per space. But you need an administrator to install the App.

Regards,  
Stephan (I am the CEO of EPS, the vendor of the Page Tree Creator)

comments: author: Eijaz Sheikh
body: Hi Stephan,

Does it put a unique page number automatically in the Title when a Page is created? Currently i donot see it, except for Page Tree macro.

Say, If i place a 'Create Page' button on a Main page and click it to create Child pages, will the pages be titled with unique numbers? Where do i need to insert the Page Tree creator macro?


author: EPS Software Engineering AG
body: Hi Eijaz,

About the unique page number:

1. Define a consecutive tag under Space Tools -\> Add-ons -\> Consecutive Tags; e.g. __Page_UID__. The tag has to be defined in the target space.
2. Use this consecutive tag in the PTC Template page title; e.g. __Page_UID__ __Page-Title__. This Template can be in the PTC Template Space.
3. Place a PTC Button macro at the main page (target space) and use the PTC Template as Source Page.

We could also schedule a screen sharing meeting. We could explain everything in detail about how it works.

Regards,  
Stephan


author: avinsinghal89
body: HI Stephan,

I have similar requirements can you please guide with the same .

Can we have a meeting .

Best Regards

Avin


author: EPS Software Engineering AG
body: Hi Avin,

Yes, of course. Can you send me an email with a suggestion for an appointment (info@eps.ch)?  

You can test the functionality under the following link: [https://focuspro.eps.ch/display/PEPSMarktExample?\&pagepropertiesreport](https://focuspro.eps.ch/display/PEPSMarktExample?&pagepropertiesreport).  
In addition to the sequential number, months are also entered here. Of course, it is also possible to configure only the number.

Regards,  
Stephan


author: Nic Brough -Adaptavist-
body: Natively, no, the page title is just a string, given by the user, there's no way to inject something in there even with a template.

You could use some code that could re-write the page title as it is saved, I think, but you'll need an add-on to do it, but you might find it struggles with the uniqueness and incrementing if pages are saved at similar times.

I'd be tempted to just use the page ID - that's immutable, numeric and increments as you create new pages, and can be used to jump straight to a page in a url.

comments: author: Eijaz Sheikh
body: Can you elaborate with an example on how to use a pageID from within a template? Right now i can only use the HTML macro which is enabled. JQuery / Javascript works in it fine.

OR is pageID a parameter that can be used in the Create From Template macro?


author: Nic Brough -Adaptavist-
body: I've never done it in a template. Never had any need for it. The one time I was asked for something like this, the actual problem the users were trying to solve with numbering was easily and better solved by using Confluence functionality that they were unaware of.

I know the page id is available to pages, as I've written user macros (to help with debugging) that can display the id of the current page. However, I don't think it's available in a template or page create, because the ID is not allocated until the page is created.


author: Markus P?hler
body: Hello NIc, what exactly did you mean by:

> by using Confluence functionality that they were unaware of.


author: Nic Brough -Adaptavist-
body: The problem they were needing help with was solved with something that Confluence does off-the-shelf


author: Markus P?hler
body: Hi NIc, yes, I understood this so far :)

My question was ment to be: What exactly is this functionality Confluence has, that has solved it? Do you know?


author: Nic Brough -Adaptavist-
body: I can't remember, it's been a while.

This problem came to me as "we want to have unique numbers in a page name that is already unique and doesn't need it". They were trying to solve a particular problem that was better solved with something else in Confluence.

The answer was to get them to explain why they thought they wanted the number - the answer to that was that they didn't, it's a silly solution to a problem already solved with something they didn't know Confluence already did.


author: Markus P?hler
body: I know, I have read the tread :)

Here is my use case: Today we have to fill in paper forms and we have to fill in a unique identifyer that is a combination of a username, date and upcounting number. Combined, this unique identifyer is unique over all sheets filled in in the company.

The idea is to replace this paper form by a template in confluence.

The requirement is to still have a unique identifier (does not have to be a combination, just unique and automated) on all instances after they have been created. In case it is printed, it should still be unique.

How yould you solve that with built in confluence functions?

BR


author: Nic Brough -Adaptavist-
body: You already have a unique identifier for every page. In fact, two, with different patterns.

The page id is a unique identifier inside Confluence. It also enables you to generate a "tiny" link for the page which, because it is derived from the id, is also unique and gives you the bonus of being able to use it as a url.

If you wanted username and date embedded (assuming they're not already the creator of the page and date of creation), you might want to add them as page properties. A sequential counter is something you'd need to code for though.


author: Louise H_
body: Yes, but the question is how to integrate this page ID somewhere INTO the page. To see the id, currently you need to go to Page Information. I do not know any macro which is able to show the page ID on the actual page or put it as a label of the page, etc.

Using confluence server.


author: Nic Brough -Adaptavist-
body: On Confluence server, you could create a user macro that puts the page id in the content.

Not sure why you would want to though, it's of no use to your readers.


author: Louise H_
body: OK thanks, User Macros are disabled for normal users in our company - guess this is a dead end for our team then.

And thanks for worrying about the usefulness of what I am asking - if I ask I also have a need for it ;) Our team would like to have a unique identifier number per created page to be able to refer to an exact page/content in a space, to make communication about this content very clear (no mis-communication about what we are talking as we have the unique identifiers).


author: Nic Brough -Adaptavist-
body: Your admins could write the macro, and then your normal users could add it to the pages that they want it on.

On the point about mis-communication - you don't need the page id because there are at least two other (more useful) unique identifiers for a page.

If the title of the page does not have non-standard characters, then the page has a human-friendly URL. If it does have unfriendly characters, then the page still has two unique URLs - short and long (the long one has the page id in it).

You can use either fixed URL, (or the human-friendly url if it can be done) for a reference to an exact page. This is better than showing an id on a page, because people being told to refer to the reference can simply click on the URL, not have to rebuild it based on the page id.