Many people asked me about adding or deleting menu items in UCM, it is easy to do this with UCM.
The steps to customize menus
1- Create a custom component, or use an existing one
2- Add new resource file to the component that file type is "HTML Include"
3- Add new include with the following name "custom_finish_layout_init" where it is an existing include that creates menus and we want to customize it
3- Inside that include write the following
// First we will call the parent definition for menus
<$include super.custom_finish_layout_init$>
// If we want to delete "My Profile" link
navBuilder.deleteItem("MY_PROFILE");
// Now we will add new menu item and we will add one child link to that menu item
// Check if the menu has been added before
<$if not MyScreensMenu_included$>
// add a drop-down menu, or a tray to the UI, that new menu item will be called "My Screen"
navBuilder.addChildNodeTo('NAVTREE', 'collection', 'id==MyScreens', 'label==My Screens');
//Now check if we are using Top Menus layout
if (navBuilder.menuB)
navBuilder.menuB.addTopLevelNode("MyScreens");
//Or we are using Trays layout
else if (navBuilder.trayA)
navBuilder.trayA.addTopLevelNode("MyScreens");
// Flag that the new menu item has been added
<$MyScreensMenu_included = 1$>
//At last add the link to the menu item that link called "Link 1"
navBuilder.addChildNodeTo('MyScreens', 'item', 'id==link1', 'label==Link 1', 'url==http://www.google.com');
<$endif$>
The code in blue is javascript code and in red is idocscript, also notice the following idocscript variable "MyScreensMenu_included" only defined when we used it that is because idocscript language doesn't need you to define variable before using them (Unchecked types language)
2 comments:
Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!
Thanks for your words. I will try to improve my blog especially during this new year 2010.
Post a Comment