Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since OG 7 makes heavy use of Panels I think a cTools content type would be very handy to use for rendering the menu in a pane.
By having this functionality as a cTools content type the settings for the pane is exportable. The setting for OG Menu that is link menu title to group node is now optional per pane. By having the group context configurable it makes the settings very flexible.
After a IRC chat with rv0 this functionality should be added as a submodule so that OG Menu does not add more dependencies than it has to. The supplied submodule adds a cTools content type that has settings for
- Provided context "Organic groups membership: Group gid"
- Link the pane title to the group node
- Override title text (standard)
Comment | File | Size | Author |
---|---|---|---|
#39 | provide_ctools_content-1274250-39.patch | 6.25 KB | mglaman |
#37 | interdiff-1274250-35-37.txt | 3.17 KB | mglaman |
#34 | Menu-index.PNG | 48.88 KB | heyyo |
Node template | organicgroups_1315576261826.png | 18.17 KB | pontus_nilsson |
Comments
Comment #1
pontus_nilssonSupplied file provides the submodule as a patch instead of the archive in the post above.
Comment #2
rv0 CreditAttribution: rv0 commentedhaven't tested yet and won't have the time to do so soon, but if people want this they should help out by testing it and posting feedback in here!
just did a quick read of the patch, some minor comments:
- isn't panels needed as a dependency?
- please try to follow the coding standards a bit more.. Like place a "dot" after a comment.
- empty lines should be empty, i spotted at least one which has spaces
- when placing comments in array definition, please place them after the relevant key=>val unless it's really long
- i've never seen ctools spelled like cTools before. be consistent.
it seems like a nice addition to OG Menu, hope to get some feedback from users.
Comment #3
teekay78 CreditAttribution: teekay78 commentedI tested the patch using og_menu from 11/10/26.
It works fine, as long you have only one single menu in the group.
og_menu allows multiple menus per group. As soon you add a second menu, the menu pane disappears.
Thanks!
Comment #4
pontus_nilssonNew patch with fixes from comments in #2.
Regarding #3. I guess it will be hard to determine which menu should be rendered. Should we have a setting render the n:th menu in the group or should it be render first found menu or render all menus?
Comment #5
rv0 CreditAttribution: rv0 commentedNice to see this is still going on.
About the multi menu feature:
I really dont get the point of the legacy OG Multi menu thing, I don't like how it currently works.
It seems to merge the links and places the title of the current node on top. Seems "weird" to me.
Haven't used it myself until I got a patch for it recently. Don't really know what to do with it.
Comment #6
fabsor CreditAttribution: fabsor commentedWhy not make the plugin add multiple content types, one for each menu in each group? that way, you will be able to select the appropriate menu based on the current context.
Edit: Hmm... I guess we still would have to have a "N:th menu in group" kind of pane if we want to be able to create new menus without changing panels though.
Comment #7
pontus_nilssonNew patch renders through menu_block with settings for depth.
Comment #8
rv0 CreditAttribution: rv0 commentedA quick look at the patch, I see $form['depth'] setting for max depth of the menu tree
afaik, drupal limits menu depth to 9: http://api.drupal.org/api/drupal/includes%21menu.inc/constant/MENU_MAX_D...
maybe best to use that constant and the range function to create the array: http://www.php.net/manual/en/function.range.php
Why the menu_block dependency? what does it do?
Comment #9
pontus_nilssonI was thinking menu_block does some pretty cool stuff. For example only render first level of the menu in the first pane, render the second level starting at the active menu trail etc.
Comment #10
pontus_nilssonScrewed up the last uploaded patch, new file comes here.
Comment #11
pontus_nilssonNew patch provides some sane defaults if they are not set in the pane.
Comment #12
gdl CreditAttribution: gdl commentedThanks for the patch! Two minor suggestions on the comments:
1) "dierctory" should be "directory"
2) As I understand them, the current comment style guidelines suggest that the first, and probably only, line in the comment block should be:
I can't comment on how well the code works, however, since I haven't actually tested it.
Cheers,
-G
Comment #13
denny84 CreditAttribution: denny84 commentedWhere is the function
og_menu_get_menus(array($gid));
coming from?Comment #14
denny84 CreditAttribution: denny84 commentedAAAAAAh ....... this is 2.x ...... for 1.x its
og_menu_get_group_menus(array($gid));
Comment #15
rv0 CreditAttribution: rv0 commented@ denny84
that function was renamed, see #793854: og_menu inadvertently implements hook_get_menus()
Comment #16
denny84 CreditAttribution: denny84 commented@rv0 You are right. I didnt know that.
Comment #17
fabsor CreditAttribution: fabsor commentedWhy do we need to create a new module for adding this functionality? CTools is plugins are only loaded if the proper modules that define the plugin types are enabled, so I don't see why we couldn't just add the plugins directly to the main module. You don't have to add panels and CTools as dependencies, the plugin just isn't loaded if they are not enabled.
Comment #18
rv0 CreditAttribution: rv0 commentedif that is indeed the case, an include file according to whatever the standard is for ctools would be enough
Comment #19
rv0 CreditAttribution: rv0 commentedRE: #17
If anyone can provide a clean patch without the new module, I will commit it.
Same goes for #1871390: ctools content type plugin for OG Menu 3.x
Comment #20
neclimdulAfter reading the patch I was about to echo #17 but I see everyone is on the same page. Title was bothering me though.
Comment #21
bkildow CreditAttribution: bkildow commentedI'm merging #1871390: ctools content type plugin for OG Menu 3.x into this one as suggested. Patch is attached and is not using a separate module as suggested in #17. This is for 7.x-3.x version of Og Menu.
Comment #22
bkildow CreditAttribution: bkildow commentedComment #23
bkildow CreditAttribution: bkildow commentedI've attached a new patch fixing some white spaces.
Comment #24
zipymonkey CreditAttribution: zipymonkey commentedI installed patch #23 and used it to a add og_menu content to a panelized group node. The menu show up properly but the following error was displayed. I'm getting the context from the group node.
Notice: Undefined property: stdClass::$etid in og_menu_pane_content_type_render() (line 73 of /Users/zipymonkey/Sites/acquia_d/sites/og.localhost/modules/og_menu/plugins/content_types/og_menu_pane_content_type.inc).
Comment #25
bkildow CreditAttribution: bkildow commentedNew patch attached that should address #24.
Comment #26
rv0 CreditAttribution: rv0 commentedA quick glance at the latest patch:
Why the menu block dependency? Please remove.
Patch does not follow drupal coding standards for several reasons:
- comments (esp for hook implementations)
- spacing in if statements not always correct
Comment #26.0
rv0 CreditAttribution: rv0 commentedAdds cons for having this feature.
Comment #27
heyyo CreditAttribution: heyyo commentedAny chance to see this patch commited ?
Comment #28
rv0 CreditAttribution: rv0 commentedAs stated in #26, this still needs work
Comment #29
heyyo CreditAttribution: heyyo commentedIs the menu block dependency should still be removed ?
I just retest this patch which works really nice inside Panels.
Menu Block gives the possibility to display only part of a menu with settings of level + depth.
I add for my need a "menu_index" settings in the pane to be able to display any menu on my group panel page.
In my case I need one menu for navigation and another one in the footer as explained in issue #2179789: Howto display several menus on group page
I also needed to add a sort by title in function og_menu_group_menus() to reflect the same order used on the page group/node/XXX/admin/menus
I tried to correct the code according to Drupal standard.
Please my first Drupal patch attached
Comment #30
rv0 CreditAttribution: rv0 commentedI don't see why the menu_block dependency is there, when I check the patch I see some duplication from menu_block, but no menu_block functions.. Correct me if I'm wrong.
Comment #31
heyyo CreditAttribution: heyyo commentedThis line permits to render only part of a menu:
$rendered_menu = menu_tree_build($conf);
http://drupalcontrib.org/api/drupal/contributions!menu_block!menu_block....
Comment #32
heyyo CreditAttribution: heyyo commentedIf you don't want to add this dependency to menu_block it's also possible to show those options of menu_block only if menu_block is enabled. with module_exists()
Comment #33
heyyo CreditAttribution: heyyo commentedHere it is a version of the same patch without dependency on "Menu Block"
When configuring the Og Menu pane related settings to Menu Block will be disabled with description explaining that Menu Block is required to use them.
I also fixed og_menu_index in select field which couldn't equal to 0, limitation of #options:
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
So the index of the first menu is now 1 not 0.
Comment #34
heyyo CreditAttribution: heyyo commentedComment #35
timwoodPatch from #33 rerolled for latest -dev code as of April 9, 2014 (up to commit 90c540c).
Comment #36
mglamanNeeds work. Working on re-roll.
Context isn't passed if this is optional, needs to be required.
If the group is also a group content type, it displays parent menu and not the current group's menu.
Comment #37
mglamanRevised patch. This taps into
og_context()
like the blocks to ensure a group's proper menu is display.If viewing a group, displays group. When view group content, menu displays. When viewing a subgroup, that group's menu displays.
Comment #38
mglamanComment #39
mglamanRealized that patch that was re-rolled, and previous, had a lot of extra cruft outside of patch scope. Here is a proper patch that just adds Ctools API hook and the content pane. Previous interdiff relevant, as it shows switch from Ctools context to the OG context function.
Comment #40
Chris Burge CreditAttribution: Chris Burge commentedDuring testing, I noticed the menu order is reversed when rendered.
For example, there are two menus: Group Menu 1 and Group Menu 2. The menus were created in that order and are listed in that order on the group's menu page (group/node/%/admin/menus). The patch provides a 'Menu index' field with the following options available: 'First Menu, 'Second Menu', and 'Third Menu'.
Observed Behavior
When 'First Menu' is selected, Group Menu 2 is rendered. When 'Second Menu' is selected, Group Menu 1 is rendered.
Expected Behavior
When 'First Menu' is selected, Group Menu 1 is rendered. When 'Second Menu' is selected, Group Menu 2 is rendered.
Running $menus through array_reverse() corrects this issue.
Comment #41
Chris Burge CreditAttribution: Chris Burge commentedAfter further testing, the behavior I described occurs when the 'Automatically create menu for new Organic Group' option is selected (admin/config/group/og_menu). It does not occur when this option is not selected.
Perhaps instead of keying on 'og_menu_index', we should key on 'menu_name'. This is the approach taken by #2328915: Method to assign weights to menus. This approach would also populate the 'Menu index' field from the database instead of hardcoding 'First Menu, 'Second Menu', and 'Third Menu'.