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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hide element based on group membership and pageid.

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

1 answer

1 accepted

0 votes
Answer accepted

Hi @Henrik Juel Petersen ,

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

480 views 24 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you