Skip to end of metadata
Go to start of metadata

Personal Menus

Create custom menus specific to the logged in user or groups they are in...

Requirements

Overview

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...

Example Scenario

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.

Creating the "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).

Logged-in users

For logged in users, the "Account" menu will consist of the following options:

  • History — enables the user to see which pages they've recently looked at
  • Profile — allows the user to access their personal profile
  • Log out — let's them log out

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.

Logged-out users

For logged out users, the "Account" menu will consist of the following options:

  • Log in

We could also include "History" and "Sign up", however there are currently some issues with those items:

  • History — The history option only becomes available when a user has viewed more than one page. Although we can be 99% certain that a logged in user has visited at least one page, that's not the case with logged out (anonymous) users.
  • Sign Up — There is currently no setting in the link-to macro for creating a link to the sign-up page. If this option is needed you can use the fixed URL to the sign-up page.

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.

Adding the menus

To make the changes take effect, simply paste in the markup for the menus in to either the pre-menu or post-menu fields.

Hiding the original "Account" menu

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;
}

Hints and Tips

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.

Frequently Asked Questions

None at present.