Friday 21-11-2008
About Us | Contact Us | FAQ | Support | Links
Coldfusion Custom Tags, CFXs, CFCs, Full Applications and more!
< Built by ColdFusion Developers, for ColdFusion Developers >
 
Home | Tag Categories | Latest Tags | Top Rated Tags | Top Selling Tags | My Account | Search | Sell Your Tags | Tags A-Z
Tree-like Menu System (Server Side)

Tree-like Menu System (Server Side) - Server-side system for ColdFusion 5.x
Developer Name: Martin Baur
Company Name: MindPower, IT Services
Email Developer Email Developer:
Latest Version: 1.0
Price: $30
License: One Copy per Website.
Encrypted: Yes
Average Rating: Not Rated
Times Rated: Not Rated
Rate This Tag:


Tag Comments

There are no comments for this tag yet!


What Is Tree-like Menu System (Server Side)?
Include one template in your application.cfm, define a menu array any way you want, have it translated if needed, and there you go: a server-side menu system like it is in use on www.mindpower.com. Very easy to use, no javascript. Works independent from the browser. Use CSS to your liking.

<!---

   inc_menusystem.cfm

   (c) 11/2003 by Martin Baur, www.mindpower.com

   Version 1.0     2003-11-9       Created


   A server-side tree-like menu system

 

   The following describes a ColdFusion construction which generates a tree-like menu which expands/collapses menu entries.

   It does not use javascript, so it works with any browser.

   It uses CSS only a bit, so you are free to customize your menu using your standard CSS techniques, especially cSS for the <a> tag

   It expands only the currently selected menu branch

   It is designed to offer easy translation to other languages because only this definition file must be translated

   The menu definition file to inlcude can be built based on any access controll, user authentication etc.

 

   Requirements

   ColdFusion 5.0 or higher

 

   Setup of te definition file

   The definition of the menu is done by creating one or more arrays with any possbile variable name that ColdFusion allows.

   All entries of this array are structures.

   The following describes the entries.

   Below, you find a sample of an array that is actually in use on www.mindpower.com


   Each menu item structure has the following attributes, some mandatory, most optional

   level            mandatory       hierarchy level of this item, level being >= 1
   parent           mandatory       parent item >= 0
   link             mandatory       visible link object (either text or whatever may be within <a> and </a>.
   name             optional        name attribute in the <a> tag
   url              optional        href attribute in the <a> tag.
                                    if missing, #script_name# is used automatically
   title            optional        title attribute in the <a> tag
   style            optional        style attribute in the <a> tag
   id               optional        id attribute in the <a> tag
   class            optional        CSS class attribute in the <a> tag
                                    AND also class in <a><span class="...">link</span></a>
   class_selected   optional        CSS class for the links currently selected
   target           optional        target attribute in the <a> tag
   bullet           optional        within the <a>..</a> there will be an image created on the left of the link
   onclick          optional        onclick attribute in the <a> tag, Do escape any double quotes in the assignment AND for the runtime assignment


   The very first structure of this array MUST exist and contains some additional attributes that apply to the entire menu

   level            mandatory       always 0
   parent           mandatory       always -1
   link             mandatory       text to show if NO menu item is selected, can be empty of course
   class_selected   optional        CSS class attribute in the <a> tag IF a menu item is selected
   level_x_spacing  optional        line spacing (i.e. <br>) which separate menu rows of level x where x >= 1
   indent_count     optional        repetion of &nbsp; to insert to the left of the <a> tag, multiplied by (current level - 1)


   Multiple menu arrays can be created to populate multiple menus on the same page

 

   The following lists all public functions.


   function write_menu (mtree, p, lvl, complete)

        mtree       the menu to use
        p           the parent where the display should start with
        lvl         level to show
        complete    if true, all menu children with levels >= lvl are displayed (=expanded)

        To display only the top level of the menu:

        write_menu (menu, 0, 1, false)

 

   function get_menu_path (mtree, id)

        mtree       the menu to use
        id          the current item

        returns the menu path starting with the top level using mtree[].link

 

   function get_menu_parent (mtree, id)

        mctree      the menu to use
        id          the current item of which the parent should be foudn

        returns the parent menu item number, if no parent 1


   function validate_url_params (mtree)

        mctree      the menu to use

        validates the url parameters based on the current menu.

 

   Most of the time, write_menu and get_menu_path will be probably the only functions that one needs.

   The system automatically uses two URL parameters which are appended to the URL

   l1     currently selected menu
   ll     previously selected menu
   lang   uses a ISO code for language selection . This can be used to load the appropriate menu definition file.

   All parameters are automatically created if not existing.


   Example of integration in the homepage:

   1. Place this in your application.cfm to make sure that we can use validate in step 2

   ------
      <cfinclude template = "inc_menusystem.cfm">
   ------


   2. Now you can use the definition file based on some language selection. Of course, there need not be a language selection.
   ------
      <cfparam name="url.lang" default="de">

      <cfif url.lang is "de">
         <cfinclude template = "menu_de.cfm">              // This is the menu definition, this one in German
      <cfelse>
         Please don't mess around with URL parameters.<br>
         Currently, only DE is allowed for the language.
         <cfabort>
      </cfif>

      <cfscript>
          validate_url_params (menu);                      // this mandatory call makes sure that the url parameters are within range for this menu
      </cfscript>
   ------

   Now you can use the current menu path already in your <title>...</title>
   ------
      <title>MindPower &ndash;
         #get_menu_path (menu, url.l1)#
      </title>
   ------

 


   The rest of this file shows the actual menu defintion that is currently in use on www.mindpower.com.

   Note that each menu item number is assigned to a constant.

   This allows for convenient switching in the main page based on the url.l1 parameter like this:

   <cfif url.l1 is 1>
      <cfinclude template = "inc_welcome.cfm">

   <cfelseif url.l1 is cRemoteEdu>
      <cfinclude template = "inc_remote_edu.cfm">

   <cfelseif url.l1 is cManuals>
      <cfinclude template = "inc_manuals.cfm">


--->

<cfparam name="pic_ext" default="#pic_ext#">

<cfscript>

   menu = ArrayNew (1);

   l1 = ArrayLen(menu) + 1;
   menu[l1] = StructNew();
   menu[l1].parent          = -1;
   menu[l1].level           = 0;
   menu[l1].link            = "Willkommen!";
   menu[l1].indent_count    = 4;
   menu[l1].class_selected  = "selected";
   menu[l1].level_1_spacing = 1;
   menu[l1].level_2_spacing = 0;

   l1 = ArrayLen(menu) + 1;
   cAngebote = l1;
   menu[l1] = StructNew();
   menu[l1].parent = 0;
   menu[l1].level  = 1;
   menu[l1].link   = "Angebote &amp; Dienste";
   menu[l1].class  = "hot";
   menu[l1].bullet = "/symbols/bullet_orange.#pic_ext#";

      l1 = ArrayLen(menu) + 1;
      cADSL = l1;
      menu[l1] = StructNew();
      menu[l1].parent = cAngebote;
      menu[l1].level  = 2;
      menu[l1].link   = "ADSL, Firewall, WLAN";
      menu[l1].bullet = "/symbols/bullet_orange_small.#pic_ext#";

 

...

</cfscript>



 


< Business Strength Coldfusion Custom Tags >
Sitemap | Privacy | Branding | Web Services | Support | Contact Us
PageCLixUid