Dynamically create horizantal CSS menus.

Based on ?superfish? type CSS menus (see link), this class allows dynamic generation of CSS and HTML to produce horizantal menus at runtime.
This does not actually product Superfish functionality, but the code should be compatible with adding Superfish.
It is advisable to cache the menu if possible, as there is considerable overhead to running this every time the script is accessed and on a busy site with many buttons and layers could have a significant detrimental effect on performance. Simple example adding a three button menu where second button has a sub-button:

$hmenu = new HMenu;
$hmenu->addButton('Home', '/');
$hmenu->addButton('Products' '');
$parentid = $hmenu->getLastID();
$hmenu->addButton('Product One', '/prod1/', 'Product One', 2, $parentid);
$hmenu->addButton('Product Two', '/prod2/', 'Product Two', 2, $parentid);
$hmenu->addButton('Contact Us', '/contact/');

// then use...
// $hmenu->generateCSS() at the end of your  section
// and $hmenu->generateHTML() where the menu would go
link http://users.tpg.com.au/j_birch/plugins/superfish/
see \global\VMenu
package dstruct_presentation
todo This was written some years ago and probably needs updating to fit more recent menu technologies

 Methods

Add a button to the menu.

addButton(string $text, string $url, string $title, \number $level, \number $parentid, string $onclick) 

See the class description for a simple example which includes adding buttons.

Parameters

$text

string

Button text

$url

string

Link for anchor

$title

string

Text for title of anchor

$level

\number

Level of the button (1, 2 or 3)

$parentid

\number

ID of the parent button.

$onclick

string

Any JS for the onlick of the anchor

Generate the CSS portion of the menu.

generateCSS() : string

Creates a style tag with CSS for the menu.
If you have put in CSS and JS directories, then script tags will also be output with links to

/[jsdir]/menu.js
/[jsdir]/supersubs.js

If you have set and image directory then it will try to use a dropshadow with the file

/[imgdir]/shadow.png

Returns

string

Generate the HTML portion of the menu.

generateHTML() : string

Returns

string

Get ID of last button

getLastID() : integer

Returns

integer

Get the next button ID.

getNextButton() : \integer.

Useful when using addButton()

Returns

\integer.

Background colour.

setBGCol(string $bgcol) 

Parameters

$bgcol

string

Hex colour code e.g. ec4a8f

Background :hover colour.

setBGHoverCol(\string. $bghovercol) 

Parameters

$bghovercol

\string.

Hex colour code e.g. ec4a8f

Border colours.

setBorderCols(array $bordercols) 

Array with 4 elements for top, right, bottom and left. Elements should be hex colour codes e.g. ec4a8f

Parameters

$bordercols

array

Border widths.

setBorderWidths(array $borderwidths) 

Array with 4 integer elements for top, right, bottom and left.

Parameters

$borderwidths

array

Button height.

setButtonHeight(integer $buttonheight) 

Parameters

$buttonheight

integer

Button width.

setButtonWidth(integer $buttonwidth) 

Parameters

$buttonwidth

integer

In pixels

Set CSS file directory.

setCSSFileDirectory(string $css_dir) 

Parameters

$css_dir

string

Default font colour.

setFontCol(string $fontcol) 

Parameters

$fontcol

string

Hex colour code e.g. ec4a8f

Font :hover colour.

setFontHoverCol(string $fonthovercol) 

Parameters

$fonthovercol

string

Hex colour code e.g. ec4a8f

Font style is italic?

setFontItalic(boolean $fontitalic) 

Parameters

$fontitalic

boolean

Font size.

setFontSize(float $fontsize) 

Parameters

$fontsize

float

Font weight.

setFontWeight(string $fontweight) 

Parameters

$fontweight

string

e.g. bolder

Set the image directory.

setImageFileDirectory(string $img_dir) 

Expects to find a shadow.png

Parameters

$img_dir

string

Set the javascript file directory.

setJSFileDirectory(string $js_dir) 

Parameters

$js_dir

string

Menu margin

setMargin(integer $margin) 

Parameters

$margin

integer

In pixels

Menu drop in pixels

setMenuDrop(integer $menudrop) 

Parameters

$menudrop

integer

Set the float (left or right) of the menu.

setMenuFloat(string $menufloat) 

Parameters

$menufloat

string

Set the width of the menu.

setMenuWidth(integer $menuwidth) 

Parameters

$menuwidth

integer

In pixels

 Properties

 

$bgcol : string
 

$bghovercol : string
 

$bordercols : array
 

$borderwidths : array
 

$buttonheight : array
 

$buttonwidth : array
 

$css_dir : \unknown
 

$fontcol : string
 

$fonthovercol : string
 

$fontitalic : boolean
 

$fontsize : float
 

$fontweight : string
 

$id : integer
 

$img_dir : \unknown
 

$js_dir : string
 

$level1 : array
 

$level2 : array
 

$level3 : array
 

$margin : array
 

$menudrop : integer
 

$menufloat : string
 

$menuwidth : integer
 

$nextbutton : integer