Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

User Macro show unpublished pages

oguz611
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2020

Hi,

 

i want to check with a user macro, if a page has unpublished changes or not.

 

my idea is something like this:

 

#if ( $ContentEntityObject.getContentStatusObject == "DRAFT" )
<span class="aui-lozenge aui-lozenge-success">YES</span>
#else
<span class="aui-lozenge aui-lozenge-error">NO</span>
#end

 

"$ContentEntityObject.getContentStatusObject" isnt working for me with Confluence 7. Do you guys have any ideas for me?

Thanks.

1 answer

0 votes
Dominic Lagger
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 21, 2020

Hey @oguz611 

Do you really need an user macro for this?

Out of the box, confluence brings this feature. If the page is an draft, the user who made changes is notified by a box nearby the title: 

image.png

If some other person go to this site, he won't see the changes. Only if he edit the page, then he will notice, that someone else did some changes.

Regards, Dominic

oguz611
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 22, 2020

Hello @Dominic Lagger

thank you for your answer. I need that because of administration and organization our confluence pages. We have a big Team and i want to see, on which sites are done last changes and if there are unpublished changes and who has done these changes.

I am a beginner with creating such macros and have build something like this:

## @noparams
#set ( $descendantPages = $pageManager.getDescendents($content) )

<table>
<tr>
<th>Seite</th>
<th>Author</th>
<th>zuletzt geändert von</th>
<th>zuletzt geändert am</th>
<th>Entwurf?</th>
</tr>
#foreach ( $page in $descendantPages )
<tr>
<td><a href="${req.contextPath}$page.urlPath"> $page.title </a></td>
<td> $page.creator.name </td>
<td> $page.lastModifier.name </td>
<td> $action.dateFormatter.format($page.lastModificationDate) </td>
<td>
#if ( $ContentEntityObject.getContentStatusObject == "DRAFT" )
<span class="aui-lozenge aui-lozenge-success">YES</span>
#else
<span class="aui-lozenge aui-lozenge-error">NO</span>
#end
</td>
</tr>
#end
</table>

 

everything works fine, but not the "$ContentEntityObject.getContentStatusObject == 'DRAFT'" part.

Dominic Lagger
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 22, 2020

Thanks for sharing more informations. I'm not an absoult expert in user macros, but I created a few and have some examples :) 

I thing, your approach isn't possible to do. Because an "unpublished change" ist called a draft. And a draft isn't just a flag to a page. It's a new version.

First of all, if you loop over all pages, you have to check the page and not the "contententtyobject"

$page.getContentEntityObject().getContentStatus()

But, as I said, this will probably return always "current", because the draft is always current too:

image.png

There would be an option to show all drafts in a space:

#set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set( $containerManager=$getInstanceMethod.invoke(null,null) )
#set( $containerContext=$containerManager.containerContext )
#set( $draftManager=$containerContext.getComponent('draftManager') )

<table>
<tr>
<th>Author</th>
<th>zuletzt geändert am</th>
<th>ID</th>
</tr>
#foreach ( $draft in $draftManager.getDraftsForSpace('SPACEKEY'))
<tr>
<td>$draft.getContentEntityObject().getCreatorName()</td>
<td>$draft.getContentEntityObject().getLastModificationDate()</td>
<td> $draft.getContentEntityObject().getId() </td>
</tr>
#end

But here, you won't be able to get much more informations like "DisplayName" or "title".

Hope this helped a bit

Regards, Dominic

Ran Ever-Hadani February 18, 2022

I keep forgetting that I have unpublished stuff, and it would be great if I had a list of unpublished doc at top of my overview screen.  And for that I need a macro, or at least a deep link that would take me there.  At this point the only way to get to the list is via the UI, which sucks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events