[dev] new menu & div
Peter Kocks
pk@kocks.com
Sun, 28 Jul 2002 13:10:30 -0700
Hello,
I've quietly been developing some stuff using horde for a couple
months and along the way I wrote two classes that others may be
interested in and I'm happy to submit.
One is a menu class that greatly augments the existing
Horde/Menu.php class. The class is like the existing Menu
system, but adds three new methods to the existing
menu->createItemn() and menu->printItem(). The new methods I
added are:
menu->begin()
menu->createSubItem()
menu->end()
My goals in redesigning the menu class were:
(a) to create a menu system that could be extended with sub
classes so that developers could create menus with a different
look and feel, yet is called using the same methods across
different application modules; thus, allowing for the programmer
to change the look and feel across all application modules,
without changing the code in each module.
and
(b) to allow for sub items, i.e. allow for menu items to be
grouped into subordinate items of a main menu item.
In order to code some of the first menu sub classes I liked, I
also developed a class called:
horde/Div.php
Div.php is a class for maintaining a <div> </div> like page
layout, that can be used in place of frames. <div>(s) can be
directed to maintain a "fixed" position using CSS, thereby
producing a result that is similar to using frames. However,
unlike frames the Div.php class (and the menu class that resides
within a pair of <div> tags) gets called on every page hit. This
allows you to write a menu class with rich visual features (such
as, highlighting the menu item that is currently selected) ALL IN
PHP. One could do similar things with dhtml and javascript, buy
my personal preference is to do everything in php and thereby
avoid browser problems with dhtml and javascript.
The Div.php class can also be used to solve other issues the crop
up when using frames. I like having a "login" button in one
frame, but once you login having it the text change to "logout".
This can be difficult when the login status changes as a result
of being redirected to a different frame than the one with the
login button. By throwing out the frames and replacing it with
the Div.php class, this became trivial to solve. Now, instead of
frames there are <div> tags separating page elements and the
<div> tags that contain the login button are called on every page
hit. So, you just check if the user is authenticated and put in
the appropriate button and text.
If anyone is interested in this, let me know.
--pk