Excerpt from parent page

0x7c2 December 30, 2019

hello guys, i need your help :-)
i want to include the content "123" from the parent page. If i use the excerpt macro i have to define the "page with excerpt", how can i define this without knowing the exact name of the parent "master-page"?
I mean, if someone creates a new page below "Master-Page-123" it should automatically reuse the content of the parent "Master-Page-123".

3 answers

1 vote
Alexander Wirtz December 7, 2021

@0x7c2 

I created a custom user macro for this:

 

## Developed by: Felix Schäfer & Alexander Wirtz
## Date created: 07/12/202

## @noparams

#set($parentId = $pageManager.getPage($content.id).parent.getContentId().asLong())
#set ($requestedPage = $pageManager.getPage($parentId).getTitle())

#if ($parentId)

<ac:macro ac:name="excerpt-include" ac:schema-version="1">
<ac:parameter ac:name="nopanel">true</ac:parameter>
<ac:default-parameter>$requestedPage</ac:default-parameter>

</ac:macro>

#else
Cannot show tasks on parent page because this page has no parent.
#end

I_A May 11, 2023

Hey ,

I hope you are still active and can help me here.

I have 2 Confluence servers. On one server this macro works fine and I created many templates which work perfectly. But on the other confluence server I always get "Cannot show tasks on parent page because this page has no parent."  eventhough the settings, the templates and the macro are absolutely identical.

Do you know what could be the problem?

Thank you!

Kirstin Seidel-Gebert
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.
May 11, 2023

Hi I_A May,

you can debug the macro by printing the parameters temporarily to see if something goes wrong within the code like

#set($parentId = $pageManager.getPage($content.id).parent.getContentId().asLong())
<p>$parentId</p>
#set ($requestedPage = $pageManager.getPage($parentId).getTitle())
<p>$requestedPage</p

This gives you the possibility to see if something useful comes from these calls.

Cheers,
Kirstin

0 votes
Alexander Wirtz December 1, 2021

Has anyone created this user macro in the meantime?

0 votes
Kirstin Seidel-Gebert
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.
January 6, 2020

Hi 0x7c2,

In Confluence you can write our own user macros (see Writing User Macros). You can wrap the excerpt macro with your own user macro that gets the name of the master page (parent) and puts it into the excerpt macro.

For how to get the parent of a page using Velocity code you'll have to google around (I've never done this).
I gave it a quick try and came across something like $content.getParent().getTitle(). Did not try it, though.

Cheers,
Kirstin

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events