I'm trying to set up a rule to automatically create menu items for group content with Organic Groups. Essentially I'd like to specify the parent menu and the menu item for the group that node is a member of (for simplicity, let's just assume that content can only be a member of one group). Something like this:

node:og-membership:0:entity:menu-link:mlid

Which, obviously, doesn't work, otherwise I wouldn't be asking for help. The data selector stops at "entity:". Is something like that possible, or do I need to drop into PHP to do it (assuming that I'll be able to do it there)?

Comments

ordermind’s picture

Category: support » feature
Status: Active » Closed (won't fix)

It seems to me that what would be needed is a callback that returns the group's menu item and sets the parent item to this value. As it is, there is no support for that in Menu Rules. However, feel free to create that functionality and post a patch!

colin_young’s picture

Title: Get mene parent from referenced entity » Get menu parent from referenced entity

Can I do that in the PHP code? There are tokens that allow me to get the menu-link from a node, but could the problem be that entity in my selector is of type "group" while the rule is defined as having a condition of content is of type "group content" so rules doesn't know about "group"?

As for a patch, could you give some pointers where to start? It's been a little while since I've written any custom code for Drupal, and to say I'm a little rusty would be generous.

ordermind’s picture

You need to read up on Rules API, for example at http://drupal.org/node/878718. I won't be able to help you with any more than that pointer, sorry.

ordermind’s picture

Issue summary: View changes

Added some clarification as to why it doesn't work.