{PROJECT} ../../template/doc.en.ini {GRAFIK_LINKS} $home/gifs/li_phpcms.gif {LOGO_1} $home/gifs/cmslogo1.gif {LOGO_2} $home/gifs/cmslogo2.gif {MENU} 00.08.10.06 {TITEL} Menus {CONTENT}

- Dynamic menus in phpCMS
- Creation of a menu file
- Example of a menu file
- Creation of menu templates
- Example of a menu template
- Linking of a content file to a menu option

Dynamic menus in phpCMS

If you work on larger web projects with many pages you need a navigation system. If frames or menu applets aren't acceptable for your project you have to edit each page of your project if you add one menu option. This job does phpCMS for you. phpCMS supports a dynamic menusystem.

You only have to put a menu number in your content file and add this number with some other fields in a menu file. It is possible that two or more pages have the same menu number. Now you have to create one menu template per project which describes the format of your menus. You can define a format for active and for inactive menu options.

With the call of the content file by the parser on the basis the menu number in the menu file the status of the content file is determined. Then the menus are inserted into the template. Dependent on the status of the content file the menu options are presented as active or as inactive.

Submenus are displayed only if they fit even selected upper menu option. Theoretically you can create as many as desired menu levels. Because of good operability should you should not use more than three menu levels.

Creation of a menu file

A menu file is a normal text file so you can edit this file with every plain text editor. The file extention is freely selectable. Personally, I prefer the extentions ".mnu" or ".menu".

In menu files are no comments allowed!

First you have to create the root menu level. I name this level "MAIN" because it is the main menu but the name is freely selectable. The field name for the menuname is "MENU:". A line looks e.g. like this:

> MENU: MAIN

There must be no other things in this line. Now you can define the menu options for this menu level below. You must at least define the menu class the link an the name of this menu option; other fields are optionally and freely selectable.

Further fields are for example to create graphical menus where a path to the graphic is needed or if you want to use special separators etc.

A line to define a menu option looks e.g. in that way:

CLASS; MNAME; LINK; TEXT ;

- "CLASS" field name of the menu level given in the content file.
- "MNAME" text which is shown in the menu.
- "LINK" the link to the content file or a external page. You can use the variable $home if you have defined it in the project file.
- "TEXT" this field is not needed but I use it to show a description of a menu option in the status bar if you move the mouse over a menu option.

You surely noticed the semicolons (;) as separators between the fields.etrennt.

The menu class is used to link a lower class menu option to a upper class menu option If you have the main menu option "phpCMS" on the 8th place in your main menu then the number of this menu option is 00.08. Now you have to define some sub menu options like "About phpCMS", "Download, and so on. These sub menu options now have the numbers 00.08.01 then 00.08.02 and so on.

You should define the "LINK" absolutly to your document root because it is possible to call the menu is call the menu system from different directories of your web server.

It is important that you don't use the semicolon (;) in a field because this symbol is the separator for each field. Most of the Field names are freely selectable so you can write "ADDRESS" instead of "LINK".

Exception: The field "CLASS" can't be renamed and is needed in the menu definition

The correct allocation of sub menus would not be possible otherwise.

Now you can define a submenu for each main menu option you want a sub menu. A sub menu is exactly the same as a main menue.

Example of a menu file

This is a dump of one of mine menu files:

MENU: MAIN

CLASS; MNAME; LINK; TEXT; 00.01; Galerie; $home/galerie/galerie/_parseext_; Zur Galerie; 00.02; Dokumentationen;$home/dokumentationen/doku/_parseext_; Zu den Dokumentationen; 00.03; Links; $home/links/links/_parseext_; Interessante Plätze im WWW; 00.04; Firma; $home/firma/firma/_parseext_; Über das Unternehmen in dem ich arbeite; 00.05; Renate; $home/renate/renate/_parseext_; Für meine Gattin; 00.06; Michael; $home/michael/michael/_parseext_; Das ist nur für mich!; 00.07; Security; $home/security/security/_parseext_; Alles über Security im Internet!; 00.08; phpCMS; $home/phpcms/phpcms/_parseext_; Mein Content-Management-System; | MENU: SUB1 CLASS; MNAME; LINK; TEXT; 00.01.01; Sageders Abschied; $home/galerie/sageder/_parseext_; Als Walter Sageder unser Unternehmen verlassen hat.; 00.01.02; Leo '99; $home/galerie/leo99/_parseext_; Wie ich den Leo 99 gewann; 00.01.03; Diverse Bilder; $home/galerie/diverse/_parseext_; Allerlei; 00.01.04; EBS; $home/galerie/ebs/ebs/_parseext_; Bilder vom Projekt; Creation of a menu template In menu Templates the layout of the menus is defined. A menu file is a normal text file so you can edit this file with every plain text editor. The file extention is freely selectable but i prefer the extention ".mtpl". Comments are allowed in menu templates. The Fields begin with the same symbols as in content fields or content-templates. I use the swung brackets ({}) for it. The layout definitions of all menus of a project are in this one file. A layout definition block begins with the menu name and then the keyword ".PRE" Example: {MAIN.PRE} Now you have to define the HTML-tags which you want to include before the menu: <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR> With the menu name followed by the keyword ".NORMAL" you define what the parser does with inactive menu options: {MAIN.NORMAL} Now write the HTML-tags which you want to set for inactive menu options: <TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt><A HREF="{LINK}" onMouseOver="window.status='{TEXT}';return true;" class="main"> {MNAME} </A></FONT></FONT></TD> As you can see there are Placeholder in the HTML-code which will be replaced by text HTML-code defined in the menu file. In the line above these are the fields {LINK}, {TEXT} and {MNAME}. The field {CLASS} is a field which is only used by the parser to realize the link between a submenu option and a main menu option. Now you have to define the menu name followed by the keywork ".AKTIV". This defines the HTML-tags for an activated menu option. This is the same procedure as you did on the inactive menu options. With the menu name followed by ".PAST" you have to close the layout definition of this menu level: {MAIN.PAST} After this tag you can define the HTML tags which should be insterted after the menu. Example of a menu template This a an example of one of mine menu templates:

{MAIN.PRE} <!-- Main Menu starts --> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR> {MAIN.NORMAL} <TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt><A HREF="{LINK}" onMouseOver="window.status='{TEXT}';return true;" class="main"> {MNAME} </A></FONT></FONT></TD> {MAIN.AKTIV} <TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt><B><A HREF="{LINK}" onMouseOver="window.status='{TEXT}';return true;" class="maina"> {MNAME} </A></B></FONT></FONT></TD> {MAIN.PAST} </TR></TABLE> <!-- Main Menu ends --> {SUB1.PRE} <!-- Sub Menu 1 starts --> <FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt> <BR></FONT></FONT><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0> {SUB1.NORMAL} <TR><TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt> </FONT></FONT></TD><TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt><A HREF="{LINK}" onMouseOver="window.status='{TEXT}';return true;" class ="sub"> {MNAME} </A></FONT></FONT></TD></TR> {SUB1.AKTIV} <TR><TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt> </FONT></FONT></TD><TD><FONT FACE="Arial" class="mainmenu"><FONT POINT-SIZE=10pt><B><A HREF="{LINK}" onMouseOver="window.status='{TEXT}';return true;" class = "suba"> {MNAME} </A></B></FONT></FONT></TD></TR> {SUB1.PAST} </TABLE> <!-- Sub Menu 1 ends -->

Linking of a content file to a menu option The link from a content file to a menu option will be done through the predefined field "MENU" in the content file. This could look for example like this: {MENU} 00.08.10.07 This would link the content file to the main menu option "8", the sub menu "6" and the sub menu option "7" of this level.