Simple function designed to set a function to all menu items.
class Example extends P4A { function Acopiadora() { parent::p4a(); $this->build("P4A_menu", "menu"); ... /*Add all the items and subitems that you need*/ ... $this->attachEvents($this->menu, "onClick", "menuClick"); ... } function menuClick() { $this->openMask($this->active_object->getName()); } function attachEvents ( $root, $event = "onClick", $function) { if ( $root == NULL || !strlen($function)) return; if ( $root->hasItems() ) { $root->items->reset(); while($item = $root->items->nextItem()) $this->attachEvents($item, $event, $function); } else { $this->intercept($root, $event, $function); } } }
2007-07-24: It works for me and it simplyfies my code