Web Sites Menu Filtering
I am starting to release some of the example components demonstrated at my session this year at Oracle OpenWorld 2009. In the demo I briefly showed the Web Sites menu and talked about filtering the sites in this menu based on UCM Roles. This component demonstrates how one might accomplish such a task. As other articles related to my session come on line I will inter-link them together.
You know that Web Sites menu Site Studio adds to Content Server? Can I limit the links in that list somehow? This question is asked fairly regularly. I wanted to get a sample of how one might accomplish just that out for general consumption. Once you see an example accomplishing the filtering of that list you’ll be able to apply your own specific business logic as well.
In this example we’re going to use Roles to control what web sites are listed in the menu for any given user. I’ve seen this list controlled by Roles, Accounts, Custom User Metadata and every combination of those aspects and more. This is a LOT less about securing sites away from the users (as it doesn’t do that AT ALL) and more about thinning the sites list to something more context appropriate for individuals attempting to do their everyday job.
How to do this? Override the custom_finish_layout_init dynamic html include. Here’s the important snippet (don’t worry, there is an example component!):
<$c=" STARTING EDIT HERE, JS"$>
<$if UserIsAdmin OR userHasRole("SSMENU" & siteId)$>
navBuilder.addChildNodeTo('SS_DISPLAY_WEBSITES'
, 'item'
, 'id==SS_WEBSITE_<$n$>'
, 'label==<$js(label)$>'
, 'url==<$js(siteRef)$>'
, 'icon==WebItem.gif');
<$endif$>
<$c=" ENDING EDIT HERE, JS"$>
So, sysadmin has the admin role, so s/he can see our three site samples in the web sites list:

Now, pretend we’ve created a new user named SingleSiteGuy (stay on task here, this is not a dating site side story…). We’ll give SingleSiteGuy our new SSMENUPayPalDemo Role.

And TA DA! Now SingleSiteGuy can only see the menu we gave him a role to access.

Grab the Websites Menu Filter Sample Component.