Check if page has specific parent in Velocity .vmd file
Asked by Hauke H?rhold:

I wonder if it is possible to check if a page has a specific parent in Velocity .vmd files?

I can't find anything about it.


Answers:
author: Hauke H?rhold
body: edited


author: AnnWorley
body: I am not sure I understand the terminology you are using. Please let me know if I am off on the wrong track.

The parent/child relationships between pages are recorded in the Confluence database in the **confancestors**table. You can get the pageIds for the child pages with a query like:

```
select descendentid from confancestors where ancestorid = '65585';
```

That will reveal the page ID's of all the child pages of the page with ID 65585. You can get that PageId by going to the ancestor page in the UI and choosing Page Information from the**...** menu at the top right. Then you can check the page ID of the child page and see if it appears in the results from the query.

For example, my output was:

![Screen Shot 2018-04-11 at 11.02.52 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/19325iCE87409013603A5B/image-dimensions/145x157?v=v2 "Screen Shot 2018-04-11 at 11.02.52 AM.png")

So there are three child pages of 65585, one of which is pageId 1605633

![Screen Shot 2018-04-11 at 10.59.04 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/19328i261525E9EAB5152D/image-dimensions/486x146?v=v2 "Screen Shot 2018-04-11 at 10.59.04 AM.png")

I hope this helps you reach your objective. Please let us know more about your requirements so we can provide more informed help.

Thanks,

Ann

comments: author: Hauke H?rhold
body: I just want to achieve that:  

I display an icon in front of the page title, depending on the parent of that page.  

So I have for example a page called "Installation" with 4 child-pages. All that 5 pages should have the "install-icon" in front of their page title.  
And now I have another page, called "Procedures" with 3 child-pages. All that 4 pages should now have the "procedures-icon" in front of their page title.

I could get the URL by JavaScript, split it and check for the titles, depending on that titles, the pages get their icon. I do that now. But it's not nice, not flexible. Maybe there will be added another child page in the future... It should know it automatically.  

Theoretically totally easy.  

I found stuff to create a macro which gets the parent page (and that is the big problem), and depending on the parent, it just put an image in front of the title by JavaScript (that part already works).  


author: Hauke H?rhold
body: Ok, that works...

I saw something like that (a user macro):  
## @noparams  
\<b\>Title of the parent page:\</b\> $content.getParent().getTitle()


author: Hauke H?rhold
body: Okay, that macro stuff works...

But I only get the parent of the above layer. But I want the very first parent.

So if the page tree looks like:

page1

-subpage1-1

-subpage1-2

-subpage1-2-1

-subpage1-2-1-1

-subpage1-2-1-2

-subpage1-2-2

-subpage1-3

page2

-subpage2-1

-subpage2-1-1

-subpage2-1-1-1

-subpage2-1-1-2

-subpage2-1-2

-subpage2-2

And now all subpages of page1 should give me the parent "page1" and all subpages of page2 should give me "page2".

But it's like:

If I take "subpage1-2-1" it gives me the direkt parent "subpage1-2" and not "page1".

Any ideas how to accomplish that?


Tags: atl-adm