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 |
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.
string
Button text
string
Link for anchor
string
Text for title of anchor
\number
Level of the button (1, 2 or 3)
\number
ID of the parent button.
string
Any JS for the onlick of the anchor
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
string
generateHTML() : string
string
getLastID() : integer
integer
setBGCol(string $bgcol)
string
Hex colour code e.g. ec4a8f
setBGHoverCol(\string. $bghovercol)
\string.
Hex colour code e.g. ec4a8f
setBorderCols(array $bordercols)
Array with 4 elements for top, right, bottom and left. Elements should be hex colour codes e.g. ec4a8f
array
setBorderWidths(array $borderwidths)
Array with 4 integer elements for top, right, bottom and left.
array
setButtonHeight(integer $buttonheight)
integer
setButtonWidth(integer $buttonwidth)
integer
In pixels
setCSSFileDirectory(string $css_dir)
string
setFontCol(string $fontcol)
string
Hex colour code e.g. ec4a8f
setFontHoverCol(string $fonthovercol)
string
Hex colour code e.g. ec4a8f
setFontItalic(boolean $fontitalic)
boolean
setFontSize(float $fontsize)
float
setFontWeight(string $fontweight)
string
e.g. bolder
setImageFileDirectory(string $img_dir)
Expects to find a shadow.png
string
setJSFileDirectory(string $js_dir)
string
setMargin(integer $margin)
integer
In pixels
setMenuDrop(integer $menudrop)
integer
setMenuFloat(string $menufloat)
string
setMenuWidth(integer $menuwidth)
integer
In pixels
multiarray_search(array $arr, string $dimension, string $needle) : string | false
author | ? |
---|
array
Array to search
string
Dimension to search
string
String to search for
string
false
Key if found or false$bgcol : string
$bghovercol : string
$bordercols : array
$borderwidths : 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