Forums

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

Variables in a Confluence page name

MattS
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.
December 12, 2012

I have a page named "1.0" that uses the Expand and Include Page macros to show a child page named "A Child 1.0"while staying in the parent page. Works nicely. But now I copy the parent page to a new page named "1.1" and the child page to "A Child 1.1". I have to edit the new parent page so it doesn't include the old "A Child 1.0" page. This is quite a bit of work when there are many children. I don't want to use a new space for each version.

So the question is whether there's any way to use a variable in the name of the page to be included? I want to say "Expand: Include Page: A Child %myvar%" and then define %myvar% somewhere on the parent page.

I've poked around the open issues for this at JAC, didn't see any progress on them there.

~Matt

3 answers

1 vote
Sean King
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.
February 28, 2013

I think the easiest thing to do is create a user macro with the other macros inside. That way you can set a parameter in the macro browser and that parameter can set the variables.

Or you can add variables to templates. If you create a page from a template you can add your values to the variables before the page is initially built.

Casey Schulz April 24, 2018

Could you expand on this?

I've tried the 2nd option you suggest. Using the "Create from Template" macro to call my own template that has variables you select for the page title. But when it builds the page the title isn't filled out.

1 vote
CharlesH
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.
December 13, 2012

Hi Matt,

As Bob suggests, the Reporting plugin (by your own company) will be able to pick out a variable created on the parent page, in the form of a scaffold field. You can then inject this into the include macro. Alternatively you could take the name of the current page and inject that. The mark up will be something similar to this (untested):

{report-on:injected=true}
{include:A child %page:title%}
{report-on}

Hope that helps,

Charles

1 vote
Bob Swift
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.
December 12, 2012

You could use the Run-now macro and the $page_title pre-defined variable to construct the child title. That will work for simple concatenation for child names. Otherwise, you would need a script or something else. The reporting plugin might have something similar as well.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events