Forums

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

User Macro - Get List of Templates

Jero Gonzalez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2022

Hi,

I've been creating user macro to improve workflows within our team.

One of our team's practices withing a Project's Page Tree is to name the parent page with the "Project Name" and then prefix all child page names with the project name, i.e.: "Project Name - Child Page Name".

By looking at the storage format of a page with a "create from template" macro I fished the format as:

<ac:structured-macro ac:name="create-from-template" ac:schema-version="1" ac:macro-id=ID>

<ac:parameter ac:name="templateName">
TEMPLATE_ID
</ac:parameter>

<ac:parameter ac:name="templateId">
TEMPLATE_ID
</ac:parameter>

<ac:parameter ac:name="title">
$content.getTitle() - This is the title
</ac:parameter>

<ac:parameter ac:name="buttonLabel">
Create Page
</ac:parameter>

</ac:structured-macro></p>

 

I found that I can get page information via "$content.METHOD" where METHOD comes from this documentation apparently:

https://docs.atlassian.com/atlassian-confluence/6.6.0/

so to get the parent page name I use "$content.getTitle()" because the create from template macro executed on the parent page and then gets carried over to the child page'd title.

My issue is I have not been able to retrieve the list of template names and IDs to put them in an enum type param for the user to pick the template from in the macro settings.

Another post suggested importing other classes like so:

@ComponentImport com.atlassian.confluence.pages.templates.PageTemplateManager

but I have not been able to get values from any other class other than $content.... despite importing others as instructed on another post.

Can anybody shed some light on how to go about this?

Thanks in advance!

Jeronimo

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events