Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Check if page has specific parent in Velocity .vmd file

Hauke Hörhold
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.
April 11, 2018

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.

2 answers

0 votes
Hauke Hörhold
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.
April 17, 2018

edited

0 votes
AnnWorley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 11, 2018

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

 

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

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

Hauke Hörhold
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.
April 13, 2018

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).

Hauke Hörhold
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.
April 13, 2018

Ok, that works...

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

Hauke Hörhold
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.
April 13, 2018

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events