Getting a Views Page Display to Appear Inside an Organic Group
This post is more than 10 years old. I do not delete posts, because even old information is still useful, but please know that some material on this page may be outdated or incorrect. Thanks!
I have been hitting my head against a wall for a few weeks now, trying to get a few different Views-created pages to appear as if they were normal pages inside an Organic Group (meaning they would appear inside og-menu-enabled menus for that particular group, and group blocks would also appear on the pages.
After reading up on the thread "Organic Groups and Views 2", I found that I could use an argument to help solve my dilemma. Here's how I set up an argument for a particular view:
On the page display (I could've also done this as a default), I added an argument ("Organic groups: Groups") with the following properties:
- Title: <none>
- Breadcrumb: <none>
- Action to take if argument is not present: Provide default argument
- Default argument type: Fixed entry
- Default Argument: 6116 (this is the node ID for the organic group under which this view is posted)
- Validator options
- Validator: Group nodes
- Argument type: Node ID
- Validate current user: <unchecked>
- Action to take if argument is not present: Hide view / Page not found (404)
- Validator: Group nodes
- Default argument type: Fixed entry
- Allow multiple terms per argument: <unchecked>
- Exclude the argument: <unchecked>
Doing this allows Organic Groups to treat the Views page display as if it is actually a page within that particular group. Another problem solved! (I'm really beginning to fall in love with Views... and, apparently, Views 3 is going to be even more full of win!
Another Option - Embed in Page
You can also embed a view directly in a page, using the context of that page in your view to grab the items for the group into which the view is embedded.
To do so, create a new page/story/whatever node, with 'PHP Code' as the input format. Inside the node, put in and save your node.
In the view you wish to embed (name it view_name as you used in the code above), add an argument like the following (with type Organic Groups: Groups):
- Title: <none>
- Breadcrumb: <none>
- Action to take if argument is not present: Provide default argument
- Default argument type: PHP Code
- PHP Argument Code:
nid; return $args[0]; } else { return NULL; }?>
- Validator options
- Validator: Group nodes
- Argument type: Node ID
- Validate current user: <unchecked>
- Action to take if argument is not present: Hide view / Page not found (404)
- Validator: Group nodes
- Default argument type: PHP Code
- Allow multiple terms per argument: <unchecked>
- Exclude the argument: <unchecked>
Comments