Glossary Item Box

Menu: MenuMain MenuPath MenuSite mapCms Site Map Data Source

General: OverviewCMS architecture

See Also CmsDeveloperGuide Send comments on this topic.

Context Menu

The control forms context menu of the site.

 

You can form menu using JavaScript or HTML code. If there is no context menu for the current level, then the corresponding JavaScript function is called (or HTML code is inserted). Also when on the first page of the site the corresponding JavaScript function is called (or HTML code is inserted). It is possible to select current menu item and display items of the lower level menu (relative to the current menu item).

 

Client-side API for menu creation by script (if CreateMenuUsingScript = true):

Function Description
CMS_ContextMenu_ItemCount The variable contains  number of items count.
CMS_ContextMenu_GetBegin() Function which is called at formation of the context menu before formation of the menu elements
CMS_ContextMenu_GetEnd() Function which is called at formation of the context menu after formation of the menu elements
CMS_ContextMenu_GetItem(psName, psUrl, psDesc,
    psTarget, pbIsSelected, biLevel)
Function which is called at formation of the context menu item
CMS_ContextMenu_GetWithout(menuItemGuid, name, url, desc, target,
    iconURL, iconWidth, iconHeight, isCurrMenuItem, isFirstPage)
Function which is called if there is no context menu for the current page
CMS_ContextMenu_GetIfDefaultPage() Function which is called if the current page is the main page of the site
 
 
By default ContextMenu control shows only one context menu's level. But you can change it and show multi level context menu. Define BottomLevelsNumber property for it.
 
Example for script generated menu:
<%@ Register TagPrefix="cmsmenu" Namespace="CMSLib.Menu" Assembly="CMSLib" %>

<cmsmenu:ContextMenu runat="server" CreateMenuUsingScript="True"
       PathToMenuScript="~/ContextMenu.js" BottomLevelsNumber="3" >
</cmsmenu:ContextMenu>
 
 
JavaScript file example:  

<script language="JavaScript">

function CMS_ContextMenu_GetBegin()
{

    document.write("Item count: " + CMS_ContextMenu_ItemCount);
    document.write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">");
}



function CMS_ContextMenu_GetEnd()
{
    document.write("</table>");
}



function CMS_ContextMenu_GetItem(psName, psUrl, psDesc, psTarget, pbIsSelected, biLevel)
{
    var s = "";
    for (var cms_i = 0; cms_i < biLevel; cms_i ++)
       s += "-";
    document.write("<tr>");

    if (pbIsSelected)
       document.write("<td bgcolor=\"gray\"><a href=" + psUrl + " title='" + psDesc + "' target='" + psTarget + "'>" + s + psName + "</a></td></tr>");
    else
       document.write("<td><a href=" + psUrl + " title='" + psDesc + "' target='" + psTarget + "'>" + s + psName + "</a></td></tr>");
    document.write();
}



function CMS_ContextMenu_GetIfDefaultPage()
{
    document.write("<td>Baners</td>");
}


function CMS_ContextMenu_GetIfWithoutMenu()
{
    document.write("<td>-</td>");
}

</script>

 
You can change default 'CMS_ContextMenu' prefix for the JS functions. Use JSFunctionsPrefix property to set new prefix.
 
Example for HTML menu:
<%@ Register TagPrefix="cmsmenu" Namespace="CMSLib.Menu" Assembly="CMSLib" %>

<cmsmenu:ContextMenu runat="server" CreateMenuUsingScript="False"
       BeginHTML="-= " BeforeItemHTML="[ " EndHTML="=-" EndItemHTML=" ] "
       HomePageName="Main page" WithoutMenuHTML=""
    DefaultPageHTML="" BottomItemHtmlPrefix="--" >
</cmsmenu:ContextMenu>
 

Showing Predefined menu level

With the help of a RootMenuItemGuid property you can display a certain menu level on a page. For example if you create a menu level with a list of cities through the administrative interface, you can represent this list on a site page. When editing this list through the administrative interface, it will also change on the page. At that time the menu will form a city list, which links will lead to the corresponding menu items.
You can adjust how the menu items would be represented, the same way as when drawing a common context menu.
 
HTML menu exmple for certain menu level:
<%@ Register TagPrefix="cmsmenu" Namespace="CMSLib.Menu" Assembly="CMSLib" %>

<cmsmenu:ContextMenu runat="server" RootMenuItemGuid="6e95962f-5277-451d-84ad-4b7249b33d33"
       CreateMenuUsingScript="False"
       BeginHTML="-= " BeforeItemHTML="[ " EndHTML="=-" EndItemHTML=" ] "
       HomePageName="Main page" WithoutMenuHTML=""
    DefaultPageHTML="" BottomItemHtmlPrefix="--" >
</cmsmenu:ContextMenu>
 
 

Menu: MenuMain MenuPath MenuSite mapCms Site Map Data Source

General: OverviewCMS architecture

 

 


© 2005-2007 Astron Digital Ltd. All Rights Reserved.