Here's the table design I used to implement menu favorites: CREATE TABLE menu_favs
( id serial NOT NULL, user_id integer NOT NULL, node_id integer NOT NULL, label text ) WITH ( OIDS=FALSE ); ALTER TABLE menu_favs OWNER TO postgres; GRANT ALL ON TABLE menu_favs TO postgres; Thanks. Brian Brian Wolf
Phone: 410.367.2958
Email: ..hidden..
-------- Original Message --------
I implemented it as a combination of
perl, _javascript_, a stored procedure called
custom_menu_favorites(), a Python module and a Mako template.
It required adding table menu_favs to the database to store
favorites for each user. It probably would not be that hard to
port Python to Perl and Mako template to Template Toolkit.
There are two aspects to implementing favorites: storing them and showing them. Showing favorites: ----------------------- Stored procedure custom_menu_favorites() returns a list of favorites for the current user. I added these lines to /scripts/menu.pl to call custom_menu_favorites() to call the stored procedure: my @favs = $menu->exec_method(funcname => 'custom_menu_favorites'); #my @favs = $request->call_procedure(procname => 'custom_menu_favorites'); $menu->{'favorites'} = \@favs; $template->render($menu); I added a couple of _javascript_ functions to
/UI/menu/expanding.html to show/hide favorites and these
lines to display favorites:
<ul> <li class="menu_closed"> <a href="" _onclick_="ShowFavs();">Favorites</a> <ul id="favorites" class="submenu" style = "display: none;"> <li><a target="main_window" href="">Select Favorites</a></li> <?lsmb FOREACH fav IN favorites ?> <li><a target="main_window" href=""><?lsmb fav.label ?></a></li> <?lsmb END ?> </ul> </li> </ul> Storing favorites: --------------------- Storing favorites starts with a new database table menu_favs. This line in expanding.html produces an anchor which, when clicked, displays each menu item as a checkbox + textbox. <li><a target="main_window" href="">Select Favorites</a></li> The user checks any checkboxes desired as a favorite and fills in the textbox with the name of the favorite. For example, "Parts Report". The user clicks Save button, and selections are saved to menu_favs table. Thanks. Brian Brian Wolf
Phone: 410.367.2958
Email: ..hidden..
|