I am trying to copy only a few items from menu:entity into another menu so I can use the new menu when a criteria is met. As I'm looping through each existing menu item in the hook handler function I am trying to create a new menu item but it does not seem to work when I call the new menu using echo elgg_view_menu.
foreach($value as $index => $item){
$name = $item->getName();
$href = $item->getHref();
$text = $item->getText();
$menu_item = new ElggMenuItem($name,$text,$href);
elgg_register_menu_item('no_reply', $menu_item);
}
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Alejandro@dveloper
Alejandro - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- Alejandro@dveloper
Alejandro - 0 likes
- Alejandro@dveloper
Alejandro - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
You must log in to post replies.This comment was removed by a moderator because it contained advertising.
Sorry, pressed the wrong button and removed your comment by accident. The menu API may have been added in the later Elgg version. So, use the hook approach
Ismayil,
hahaha, no problem. I updated to 2.3.0. I will test again and let you know how did it go. Like always, thanks for your replies.
Ok, I finally had the opportunity to try it. I tried the first part of the code but I am getting the following error.
Call to a member function canEdit() on null in /usr/local/elgg/2.3.0/vendor/elgg/elgg/engine/lib/navigation.php on line 484
This is how I did it.
The hook method worked though.
I just remembered that the there is an option to combine menus somewhere in the menus API. Just dig through the code.