Forums

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

Show a pages parent

Antal Vig _ Communardo
Contributor
February 17, 2022

Hi I get one Question pretty frequently from clients and so far I had no answer to them.
Is it possible to show a pages parent on a certain page, like in a page property using Scriptrunner with the "CQL Search" Makro. 

These clients typically want all fields filled on a certain page in case they print the page and it should include all context. Or have a large page properties list where they can list for everything. 

Are you guys aware of and CQL Query that lists the pages parent page or even the one above. 
I've been through this page, tried many things and found no solution for it. https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/

Just the standard list all child pages of a certain page. 
I'm sure there must be a way to display that the other way round. 

*edit
I think i need to elaborate more with a concrete example

Let me explain using this image of a page tree: Bildschirmfoto 2022-02-18 um 15.35.29.jpg

I'm on Page "Dokumentenebene". I would like to display the name of its parent on the Page.
Level: "Zwischenebene A"

And Ideally even one level above that (The parents parent). So that I can have a nice Table saying

Family: "Process family A"
Level: "Zwischenebene A".

 

Hope that makes sense. 

2 answers

0 votes
Nicolai Sibler
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 21, 2022

Hi @Antal Vig _ Communardo ,

there's a user macro for a clickable link to the parent page:

## @noparams
#
if (!$content.getParent()) <b>No parent page found</b>
#
else
#contentLink2($content.getParent() false false)
#end

Someone with more coding skills than me could modify this macro to get the parent's parent page ...

 

Kind regards,

Nicolai

0 votes
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2022

Hi @Antal Vig _ Communardo 

When you place the page tree macro it lists down the pages at the root level in space. (It also has expand option to see the child pages)

Other than that with API, you can get the list of pages at the root level in your space 

https://developer.atlassian.com/cloud/confluence/rest/api-group-content---children-and-descendants/#api-wiki-rest-api-content-id-child-get

This will surely list the pages at the root level

Let me know if you have any queries

Thanks,

Pramodh

Antal Vig _ Communardo
Contributor
February 18, 2022

Thank you @Pramodh M 
I actually need it the other way round. 

Let me explain using this image of a page tree: Bildschirmfoto 2022-02-18 um 15.35.29.jpg

I'm on Page "Dokumentenebene". I would like to display the name of its parent on the Page.
Level: "Zwischenebene A"

And Ideally even one level above that (The parents parent). So that I can have a nice Table saying

Family: "Processfamily A"
Level: "Zwischenebene A".

 

Hope that makes sense. 

Dirk Spannaus March 27, 2023

Did you find a solution for that, @Antal Vig _ Communardo ?

Antal Vig _ Communardo
Contributor
March 27, 2023

@Dirk Spannaus We tried that usermakro above for that but at the end we didn't used it as the client didn't needed that much as they originally thought :D 

## @noparams 
#if ($content.getType() == "page")
#foreach ($ancestorPage in $content.getAncestors())
$ancestorPage.getTitle()
#end
#end
Like Dirk Spannaus likes this
Dirk Spannaus March 28, 2023

I found out in between, that we can't use user macros in the cloud version 😤

Rus Yates-Aylott
Contributor
February 10, 2025

Hi. I am late to this thread but have exactly the same question.
We use Confluence Cloud and I am trying to create an automation that shows the first Parent page (the first page below the space) for any given child page.
Here's my Example:
Space
   >Parent Page 1
      >Parent Page 2
         >Parent Page 3
            >Child Page

If my automation triggers on an update to Child Page, I want the name of Parent Page 1

Is there an automation for his or a line of CQL that will do it?

Rus Yates-Aylott
Contributor
February 10, 2025

I am currently allowing there to be 5 levels of Parents (but adding more makes the If-Else conditions rather lengthy. Here's how I worked out how to do this:

Using the If..Else conditions:
If {{page.parent.title}} = <Some matching text>
or
If {{page.parent.parent.title}} = <Some matching text>
or
If {{page.parent.parent.parent.title}} = <Some matching text>
or
.
.
.
. etc etc..

Then <Take some action>

If you need to add more conditions (for example to match different page titles) you could create another If..Else branch perhaps with different actions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events