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

Creating a Custom Page Tree macro

André Lundin August 3, 2016

Hey Community!

If I use the Page Tree macro, it will show ALL the pages under root space, I want it to only show Root Page and child-pages.

I know I can edit the macro itself but I cannot restrict the macro to one Root Page since I have it in my blueprint template.(Using the special values does not solve this problem either, @self @home @parent @none)

So my example goes:

Production(space)

  • Creating(page)
    • How to create(child page)
    • How to finish creating(child page)
  • Developing(page)
    • How to develop(child page)
    • How to finish developing(child page)

What happens:

When I'm on Creating(page), this shows in page-tree:

Creating(page)

  • How to create(child page)
  • How to finish creating(child page)

Developing(page)

  • How to develop(child page)
  • How to finish developing(child page)

When I'm on How to develop(child page), this shows in page-tree:

Creating(page)

  • How to create(child page)
  • How to finish creating(child page)

Developing(page)

  • How to develop(child page)
  • How to finish developing(child page)

What I want: 

When I'm on Creating(page), I want this to show in page-tree:

Creating(page)

  • How to create(child page)
  • How to finish creating(child page)

When I'm on How to develop(child page)I want this to show in page-tree:

Developing(page)

  • How to develop(child page)
  • How to finish developing(child page)

 

I guess it's "just" a matter of creating a Page Tree Macro to only show Root Page and child-pages, but I cannot figure out how.

Does anyone have any clues?

Cheers,
André

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Steven F Behnke
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.
August 5, 2016

If you're comfortable with User Macros this is very easy to accomplish. https://confluence.atlassian.com/doc/writing-user-macros-4485.html

Example

image2016-8-5 13:17:12.png

Source

## Macro title: Children and Parent
## Macro has a body: N
## Body processing: No macro body
##
## Developed by: Steve Behnke
## Date created: 05/08/2016
## Installed by: Your name here...
##
## This macro creates a unordered list of the current page and descendants.
##
## @noparams
#set($currentPage = $pageManager.getPage($content.getId()))
#set($childPages = $pageManager.getDescendants($currentPage))
<ul>
  <li>
    <a href="$currentPage.getUrlPath()">$currentPage.getDisplayTitle()</a>
  </li>
  <ul>
  #foreach ($childPage in $childPages)
    <li>
      <a href="$childPage.getUrlPath()">$childPage.getDisplayTitle()</a>
    </li>
  #end
  </ul>
</ul>
André Lundin August 23, 2016

Hey Steven Behnke!

Cheers for pitching in. (Sorry for the delay, I've been on vacation)

I can see two problems with this macro:

  1. It won't show the parent-pages, only current page and it's children
  2. It won't show descendants, only first-level children

Also, is there a way to show all the parent pages except Space home-page? Not just the parent page of the current page. I know I can do this with:

$content.getParent().getTitle()

But I imagine I need something like this in the beginning:

$content.getAllParents('hide-space-home-page').getTitle()

ofc that's not working but maybe you see my point.

Cheers,
André

Steve Behnke [DiscoverEquip.com]
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.
August 24, 2016

I knew it wasn't too on-point, but I don't understand the requirements that great perhaps. I'll try to re-read your first post in light of your response and take another stab at this tonight (I like writing user macros, seems fun)

André Lundin August 30, 2016

How's it going mate, got any free time to look at my problem?

Cheers,
André

0 votes
Rodney Hughes
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.
August 3, 2016

I think you may not have spotted these settings at the bottom of the Page Tree macro - a value of 1 means it only shows the first level Child pages unless you click the expand buttons

image2016-8-4 18:52:57.png

André Lundin August 3, 2016

Thank you for your input Rodney,

However this does not help anything but showing the children expanded from the start or not.

Cheers,

André

Rodney Hughes
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.
August 3, 2016

mm perhaps I don't understand the objective

so what is wrong with these three results - each uses "@self" and a depth of "1" but the Top page also includes the Expand/Collapse buttons

Top page

image2016-8-4 19:22:31.png

Creating Page

image2016-8-4 19:23:20.png

Developing Page

image2016-8-4 19:24:30.png

André Lundin August 4, 2016

Hi Rodney,

The problem is Creating(page) is only showing children, not itself.
Second problem is How to create(child) is not showing Parent page, and not showing it self or other children.

image2016-8-4 12:7:58.png 

I want this to show in page-tree:

Creating(page)

  • How to create(child)
  • How to finish creating(child)

image2016-8-4 12:8:28.png

I want this to show in page-tree:

Creating(page)

  • How to create(child)
  • How to finish creating(child)

Cheers,
André 

Rodney Hughes
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.
August 4, 2016

is this close?  it is on the Creating page and shows itself and its "sister" page

image2016-8-4 20:16:29.png

Rodney Hughes
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.
August 4, 2016

or this with a starting depth of 2

image2016-8-4 20:17:57.png

André Lundin August 4, 2016

Hi Rodney,

No, sorry. You are just confirming my issues.
Changing start depth does neither hide or show other root page-links from the tree.

Creating(page) tree should only contain (start depth 2):

Creating(page)

  • How to create(child)
  • How to finish creating(child)

How to create(child) tree should only contain (start depth 2):

Creating(page)

  • How to create(child)
  • How to finish creating(child)

I do not believe this is achievable with the built in macro.

Cheers,
André

Rodney Hughes
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.
August 4, 2016

Yes - it shows more than what you wanted but it does include what you wanted i.e. my settings of Page Tree macro on "Creating Page" shows:

  • itself (in bold) and it's children (which is what you wanted)
  • its sister pages and the sister's children (which is not what you wanted - but can you live with it?)
  • The Parent is shown in the "snail trail" links above the page title (not exactly where you wanted but still visible)

I agree that to get specifically just what you want, you will need to develop your own macro or live with an oversupply of tree information

Rodney Hughes
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.
August 4, 2016

Oh, I got the macro to display itself by, instead of typing @self, typing @ followed by starting to type the title of the parent page - it then pops up as a page selection   smile

André Lundin August 4, 2016

Hi Rodney,

Yeah well this is my problem.

I don't want the oversupply of information about other pages that have nothing to do with the current page or it's children.

It shouldn't be rocket science but building more advanced custom macros is a real pain.
So I'm hoping someone else might pick up on this or send me in the right direction to someone who can.

Cheers,
André

André Lundin August 4, 2016

Yes, this is true. But as I wrote in the ticket this is no solution, I cannot restrict the macro to one Root Page since I have it in my blueprint template.

And I cannot remove it, since removing it from the blueprint requires me to add a different Page Tree macro to all pages.

Rodney Hughes
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.
August 4, 2016

and adding the expand/collapse buttons, root page as the title of the Parent page (Page Tree test) and start depth of 2

image2016-8-4 21:29:35.png

Rodney Hughes
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.
August 4, 2016

Doh!!

How is this?  It eliminates the oversupply of tree information

image2016-8-4 22:4:8.png

Use the "Children Display" macro, again setting the root page to the parent page name

image2016-8-4 22:5:35.png

As a standard macro if you copy it to another page it will be OK - except that you need to redefine the root page.  It would be handy for your application if there was a command as "@parent" instead of "@self" so not quite a winner, but much closer smile

that is the best I can do ...

 

André Lundin August 4, 2016

Hi Rodney,

Thanks for your effort to help me.
Yes I have played around with this as well, but it gives me the same issue about having to enter a specific page name as root - which wont do any good in a blueprint. As you say, a command like @parent or @rootparent would be excellent for this.

Too bad it's not possible in the current state of confluence.

Cheers,
André 

Rodney Hughes
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.
August 4, 2016

well - it is now on their radar as an official feature improvement request smile 

  https://jira.atlassian.com/browse/CONF-43372

TAGS
AUG Leaders

Atlassian Community Events