I have created a default calendar that filters by OG group using a url like 'node/$node/calendar'. When using the option to show it as a tab, the tab shows nicely on all the OG home pages. But also on all other nodes. The workaround for this is to add a Views url token that will only work on valid group page nodes. The attached patch will make the token available. To use it, you can use 'node/$group/...' as the url in a View, set it up to display as a tab, and any tab created will only display on group nodes.

Patch attached.

CommentFileSizeAuthor
#7 og.module_30.patch1.61 KBkarens
og.module_29.patch929 byteskarens

Comments

karens’s picture

See the related calendar issue at http://drupal.org/node/136968.

karens’s picture

I should maybe clarify that this needs to be an OG patch because it will make it possible to show *any* view that uses the gid as an argument as a tab on the OG home page without showing it other nodes.

moshe weitzman’s picture

I never knew about that hook. Interesting.

So the patch will only show tabs if the user is subscribed to the group. That seems like an artificial restriction. Perhaps we show tabs when this is true: og_is_group_type($node->type)? we'd have to do a node_load() to get the type.

moshe weitzman’s picture

Also, we need to document the new token. If Views doesn't provide a place natively, perhaps we should form_alter the page url form element and add some text.

karens’s picture

I was trying to avoid the node_load(), but maybe that's still best. I guess the question is when *should* someone see the tab on the home page if they're not subscribed to the group? Can they even see the home page if they're not subscribed?

As to the documentation, not sure I understand where you would put documentation. Are you saying you want it to show up on the views edit page? If so, not quite sure how to get it in there.

moshe weitzman’s picture

The group home page is always accessible to everyone. They are cries to make it different (http://drupal.org/node/83005), but thats where we are today. So similarly, these Views should be viewable by all. The nodes selected by the Views are already protected so I'm not worried about excessive disclosure. So yes, please resubmit the patch if you can with the node load. The node load is free anyway, because of the static cache in node_load(). The group node is node_loaded many times on a group page. Only he first call takes any time.

Yeah, I mean the Views edit form. I would think that a #description could be changed using hook_form_alter() just like any other form.

karens’s picture

StatusFileSize
new1.61 KB

How about this then?

moshe weitzman’s picture

Version: 5.x-1.0 » 5.x-4.0-rc9
Status: Needs review » Fixed

Tested and committed. I just tweaked the wording a bit in form_alter. Thanks much, KarenS.

I have now released RC11 - http://drupal.org/node/183062. Thats running on groups.drupal.org. i hope others keep testing these release candidates as well.

Anonymous’s picture

Status: Fixed » Closed (fixed)