How to get the name of the template used to create a page?

I'm using the Customware reporting macros to create a list of pages in a space. I'd like to be able to use the page template name as one of the column values. Is there a way to get this value?

1 answer

1 accepted

There isn't really an automatic way of doing it, but there are a couple of options.

1. Parse it from the page contents.

Typically, a page has a single template, which is specified by the wiki markup of the page containing '{live-template:XXX}', where 'XXX' is the template name. You can use a regular expression to extract this name from the 'page:body' and display it. Eg:

  {local-reporter:page:space > space:all pages}
  {report-column:title=Find Template}{report-on:page:body > text:find "live-template:([^\}]+)"|separator=comma}{report-info:match:group 1}{report-on}{report-column}

2. Store the template name as a variable in the template itself. Eg. Add a 'Template Name' field to your template like so:

{set-data:Template Name|hidden=true|value=My Cool Template}

Then, just retrieve the 'data:Template Name' value for your column.

Hope that helps!


David Peterson

Perfect! Thank You

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

374 views 20 10
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you