Add Menu::add_after()

This commit is contained in:
Bharat Mediratta
2009-01-28 19:25:01 +00:00
parent 1a62a26a36
commit 43b30c0ee2
+15
View File
@@ -129,6 +129,21 @@ class Menu_Core extends Menu_Element {
return $this;
}
/**
* Add a new element to this menu
*/
public function add_after($target_id, $new_menu_element) {
$copy = array();
foreach ($this->elements as $id => $menu_element) {
$copy[$id] = $menu_element;
if ($id == $target_id) {
$copy[$target_id] = $new_menu_element;
}
}
$this->elements = $copy;
return $this;
}
/**
* Retrieve a Menu_Element by id
*/