[All Adaptavist Apps]
There are times when you want to provide a custom menu for a particular user or group of users - that's what we aim to cover in this tutorial.
Because there are virtually unlimited different requirements for menus (eg. a menu to access personal pages, specific spaces, specific options, etc.) we're going to use one specific example that covers most of the common requirements...
In our example, we'll be creating a custom "Account" menu on the menu bar that will provide different options based on whether the user is logged in or not.
Normally, all these options are stored within the "View > Account" menu, reducing the amount of inbuilt menus on the menu bar and therefore leaving more room for your own menus.
However, you may have a need to effectively move the "Account" menu from the "View" menu on to the menu bar in order to make those options more visible - although this can't actually be done at present, we can use some tricks to get the same effect.
We're going to create a custom "Account" menu that shows different options based on whether the user is logged in or not, and then we're going to hide the "View > Account" menu.
There will actually be two "Account" menus - one for logged in users (to allow them to edit their profile, view history and log out) and one for logged out users (to allow them to log in and view history).
For logged in users, the "Account" menu will consist of the following options:
To create this menu, we use the following markup:
{show-to:groups=confluence-users} * Account ** {link-to:user history}History{link-to} ** {link-to:user profile}My Profile{link-to} ** ---- ** {link-to:logout}Log out{link-to} {show-to}
As you can see, we've used the show-to macro to ensure that this menu is only shown to logged in users – all registered users are automatically added to the confluence-users group.
For logged out users, the "Account" menu will consist of the following options:
We could also include "History" and "Sign up", however there are currently some issues with those items:
To create this menu, we use the following markup:
{hide-from:groups=confluence-users} * Account ** {link-to:login}Log in{link-to} {hide-from}
This time we're using the hide-from macro to hide the menu from users in the confluence-users group. Anyone that's not logged in won't be seen as a member of this group – even if they have a user account, they'd have to log in first before they'd be seen as being in this group.
To make the changes take effect, simply paste in the markup for the menus in to either the pre-menu or post-menu fields.
To hide the original "Account" menu, add the following to CSS Custom Styles:
/* hide separator above view > account menu item */ .menu-separator-view-1 { display: none; visibility: false; } /* hide the view > account menu item and it's sub-menu */ .menu-account { display: none; visibility: false; }
When adding personalised menus, always do so by adding (as applicable) the whole menu, not just part of the menu. Adding in the visibility macros to show or hide individual menu items can be messy and unreliable.
None at present.