Show only those Childpages that have a specific label

Christian Jurasz-Kischka October 7, 2020

I'm looking for a way to display a list (ul & li structure in the result) of all childpages of a certain page, which have a certain label.
Actually a page tree would be enough for me, but even there I would like to filter for certain labels.
The attempt with the Reporting PlugIn was not very satisfying, because everything was very slow.

2 answers

0 votes
Bill Bailey
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.
October 7, 2020

Wont the content-by-label-macro do the job? You can restrict on label and ancestor/parent.

Otherwise you can write a user macro. I built a child page by label macro based on this code:

https://github.com/unidwell/confluence-include-child-pages-macro 

With the user macro, you have complete control over the formatting.

Christian Jurasz-Kischka October 7, 2020

Hey, Bill,
thanks for your macro. It works so far. But unfortunately it only shows the first level of my childpages. And it also shows the content of the respective page.
What I'm looking for is the possibility to get all pages starting from a certain page with a certain label as a structured list. The result would be a HTML structure with many <ul> and <li> ;-)
Would this be possible with your macro?

Bill Bailey
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.
October 8, 2020

The link I sent you was to a macro I reworked to develop what you describe: an unordered list (but sortable) of child pages that match a label. In looking at the code, it only does the first level. Let me put together an article with what I have done (it is limited to children -- need to think how to extended it to all decedents).

Stay tuned!

Christian Jurasz-Kischka October 8, 2020

Hello,
that would be great!!! I already had the idea that it would be enough to create a hierarchical PageTree of all subpages and then to include the labels of the subpages as a CSS class. Then it would be possible to hide certain CSS classes, which are the page labels, by CSS.
But I am curious if you have an idea for your macro for the other layers. Thanks in advance.

Bill Bailey
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.
October 8, 2020

I have created an article that should really help you ;-)

A-Child-Page-by-Label-User-Macro 

Christian Jurasz-Kischka October 8, 2020

Hey Bill,

thanks for the link. That's quite a bit. But as you write correctly, you now have to add the subpages of the subpages as a hierarchical tree. And my know-how for programming macros is also rather hobbyistic.

Will you stick to the matter? I have found a solution for all subpages of a certain page. But unfortunately all pages are displayed in one level. I haven't found a hierarchical page-tree user macro anywhere that you could build on.
But thanks again.

Stephen Ellwood September 7, 2022

Hey Bill,

[I am also a  huge fan of user macros and would like to learn ;o)]

I followed the link and saw it was tagged for the server version.  Is there any reason why your macro would not work in the Cloud version?

0 votes
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 7, 2020

Hi @Christian Jurasz-Kischka , 

I'm trying to understand your question. 

If you have a list of items, containing parents and children like a pagetree, and filter out only pages with a certain label, how would your tree handle this? 

Say your page has a child that does not have the label you are filtering on, but a child of thát page does have the label, your tree would break, no? 

I think that's why the label filtering macro only shows a flat list of pages instead of a tree. 
Please let me know if I understood incorrect and I'll see if we can figure something else out! 

Tessa

Christian Jurasz-Kischka October 7, 2020

That is certainly true, that the described situation could be a problem.

But an idea would be, that the system only looks for labels in the subpages, if the mother page has the corresponding label.

Alternatively you could of course say that all pages are shown in the hierarchy if only one subpage has the label.

But for my problem I can make sure that there is always a continuous path for the pages ;-)

Christian Jurasz-Kischka October 8, 2020

Another idea would be to get all subpages of a page as an unnumbered list (ul - li) and to write the labels as a class into the HTML code. Using CSS you would then simply hide one or the other entry based on the label (as a CSS class).
But: Who can give me a hint on how to implement this as a macro ;-)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.2.1
TAGS
AUG Leaders

Atlassian Community Events