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.
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:
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.