Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Copper Super Contributor
Posts: 172
Registered: ‎07-06-2010

Dynamic Toolbar Menu configuration

[ Edited ]

We have multiple deployment targets for our SLX web app - development, QE, and production. One link in the toolbar menu needs to change depending on where the app is deployed to. 


I have to compile it three times, once for each environment, each with the correct URL that I want the environment pointing to. Alternatively I can manually edit the control after deployment, but that is not practical. Instead I'd like to have it look at web.config. 


Is it possible to configure an item in the Toolbar Menu to read values from web.config instead of hard-coding it via App Architect?


Posts: 629
Registered: ‎04-24-2009

Re: Dynamic Toolbar Menu configuration

The menu service (IMenuService) can be used to modify the menu on the fly (add/remove/update). You could read values from appSettings.config (preferred) and update the menu accordingly.


Example of using the menu service:


            var workSpace = this.PageWorkItem.Workspaces["ToolBar"] as ToolbarWorkspace;
            if (workSpace == null) return;
            var menuService = workSpace.WorkItem.Services.Get<IMenuService>(true);
            var mnuTools = menuService.FindMenu("mnuTools") as NavItemCollection;
            if (mnuTools == null) return;
            var navItemTest = new NavItem(
                "Hello World",

Note that if you need to modify the menu from all views on the fly (as opposed to code behind), you would probably have to create a module (i.e. assembly that implements IModule) and then modify the menu in the Load() method.