Hi,
I am trying to find a way to add an if statement to the "main layout" of a space, under site layouts, that checks if a user is a part of a group 'xxx' and if the current pageid == 'yyy'
I am able to do this through a user macro, that I can add to a page - I would just prefer not having to add that user macro to EVERY page I'd like this functionality on.
The problem is, when I add the pageid part of the usermacro to the "mainlayout" then it dont do anything.
Anyone has an idea of how to solve this?
Thanks!
Look and feel - Layout - Main layout:
This if statement is working:
#if(${action.authenticatedUser} && ${userAccessor.hasMembership('xxx', ${action.authenticatedUser.name})})
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#quick-create-page-button').remove();
AJS.$('#create-page-button').remove();
});
</script>
#else
#end
User macro that works as intended:
## @@noparam
#if(${action.authenticatedUser} && ${userAccessor.hasMembership('xxx', ${action.authenticatedUser.name})} && $content.getId() == 'yyy' || $content.getId() == 'yyyy')
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#quick-create-page-button').remove();
AJS.$('#create-page-button').remove();
});
</script>
#else
#end
I suppose this is because decorator macro doesn't include $content object.
But I think you can use something like the next script:
#if(${action.authenticatedUser} && ${userAccessor.hasMembership('xxx', ${action.authenticatedUser.name})})
<script type="text/javascript">
AJS.toInit(function(){
if (AJS.Meta.get('page-id') == 'yyy' || AJS.Meta.get('page-id') == 'yyyy') {
AJS.$('#quick-create-page-button').remove();
AJS.$('#create-page-button').remove();
}
});
</script>
#else
#end
Hi @Aleksandr Zuevich
I solved this, by keeping it in the macro, but adding the macro in the "page layout" under content layouts.
Added this line within the "page-metadata-banner" tag:
$helper.renderConfluenceMacro("{hidecreatebtnontitleandgroup}")
Up till now i haven't found a scenario, where it dosnt fix what I wanted it too.
Thanks for the input :)
/Henrik
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.