How is the TopBar generated for 1.8.1? In laymans terms please.
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
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Cash@costelloc
Cash - 0 likes
- Burgs@burgs
Burgs - 0 likes
- Burgs@burgs
Burgs - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Burgs@burgs
Burgs - 0 likes
You must log in to post replies.Since 1.8, Elgg menus are generated dynamically using ElggMenu class. This means that there is no one view that generates the entire menu, rather plugins can create hooks to overwrite menu settings and add new menu items.
Each menu has it's name. The constructor makes sure it reads all the plugins hooks and generates the menu according to the data returned by all plugin hooks combined.
Information about plugin hooks: http://docs.elgg.org/wiki/Plugin_Hooks
Here's Cash's insight into the new menu system: http://blog.elgg.org/pg/blog/cash/read/191/elggs-new-menu-system-dynamic-menus
There is also a set of helper functions that let you register and unregister menu items without having to create hooks.
http://blog.elgg.org/pg/blog/cash/read/171/elggs-new-menu-system-registering-a-menu-item
http://docs.elgg.org/wiki/Menus
Does anyone have a good way of identifying the name of a menu or item in that menu? So far I've been successful by teasing it out of the existing code, but that's a bit clunky. For example, the files link on the main menu is the 'site' menu and 'file' item. Yet the link text is "Files", is there an easier way to find the values 'site' and 'file'?
Look at the HTML. For the site menu, it should look like this:
<ul class="elgg-menu elgg-menu-site">
<li class="elgg-menu-item-blog"></li>
<li class="elgg-menu-item-file"></li>
</ul>
We should probably add menus to the developers inspection tool. Anyone interested in adding that? It would require adding a method to the ElggInspector class to pass back the menu information in a tree structure: https://github.com/Elgg/Elgg/blob/1.8/mod/developers/classes/ElggInspector.php
After much reading and much ducking as things flew over my head, I'm a little further on with this subject. What would be really helpful would be to be able to compare the relevent php files in any 1.8 Theme that mods the topbar. I've tried disecting the Facebook Theme but I can't work out which files affect the topbar menu.
Any clues anyone, or is there a easier example Theme or am I thinking about this the totally wrong way.
Anyone?
@Matt:
RE: " ..identifying the name of a menu or item.. " => I did an array walk of the menus [] to grab out all the data. Test output looks like Rpt excerpt below. Looks like this cud be then used to do some gyrations for searchingz..
[site]
`` 0:>
Data Name : activity
Text : Activity
Section : default
HRef : http://localhost/elgg1810/activity
`` 1:>
Data Name : blog
Text : Blogs
Section : default
HRef : http://localhost/elgg1810/blog/all
`` 2:> . . .
[topbar]
`` 0:>
Data Name: elgg_logo
Text : <img src="http://localhost/elgg1810/_graphics/elgg_toolbar_logo.gif" alt="Elgg logo" width="38" height="20" />
Section : default
HRef : http://www.elgg.org/
`` 1:>
Data Name: dashboard
Text : <span class="elgg-icon elgg-icon-home "></span>Dashboard
Section : alt
HRef : http://localhost/elgg1810/dashboard
Just holler if yew` wanna see any more kinda tests...
@Cash & @Dhrup - thanks, I think just looking at the HTML is the quickest/easiest solution. Adding menus to developer inspect would be good, I'll have a look at the class and see if I can come up with anything useful.
@Burgs - sorry I jacked your discussion
To get it back on track here - there isn't really a single file that lays out the menus in 1.8. In 1.7 it was done through views which was more linear and probably easier to pick up on. Now it's all done through hooks so the code for generating the menu is distributed. The advantage is that you can cherry pick what you want to adjust without overwriting anything you don't want to touch, but it might take a bit more to wrap your mind around.
Cash laid out the best explanation I've seen on the elgg blog
http://community.elgg.org/pg/forum/topic/798739/elgg-blog-elggs-new-menu-system-dynamic-menus/
That combined with the docs was all I needed, and now with a fast way to identify the menus, it's gravy.
Docs:
http://reference.elgg.org/1.8/classElggMenuBuilder.html
http://reference.elgg.org/1.8/classElggMenuItem.html
@Matt - Thanks for that.