I think I have read everything about OG Context in Views, but never succeeded at using Views with OG excepted when the View was driven by an OG aware module that sends the appropriate argument or seems to care about OG context.

I must be missing something, so after too many hours of head scratching, I would appreciate an expert eye on what I am trying to do.

I have set a very simple View that is supposed to show the nodes for a particular term. The settings are the following:

Arguments
----------
Taxonomy: Term ID
Organic groups: Groups / Provide default argument /Current group node from context / Basic validation or Group node - Node ID

Filters;
-------
Nothing or Organic groups: OG: Posts in current group =

Path :
------
og_tags/%

Values examples:
---------------_
term ID in a group vocabulary: 368
group node ID : 462

When I test the view in edit mode
- entering the argument 368 as a term ID in a group returns nothing - which is normal as no context prevails while editing a view
- entering in addition the group ID (368/462) returns the nodes filtered as expected.

When I test the view when I am on the group (gid 462) page, either from a menu item "og_tags/368" or typing manually the url "www.mysite/og_tags/368", the context is immediately lost and an empty page is displayed.

Thanks for help

Comments

dawehner’s picture

Project: Views (for Drupal 7) » Organic Groups
Version: 6.x-2.9 » 6.x-2.x-dev
Component: Documentation » Og Views

I guess you need to add the node:nid argument from the group.

But this is a support question for OG. Views does not know anything about the views integration of OG.

jvieille’s picture

Thanks for taking care and redirecting appropriately.
Do you mean an additional argument that also defaults to current group context from node? - that did not help...

dawehner’s picture

No a node: nid argument, and you change the links url to og/tags/GROUPID/termid

jvieille’s picture

Thanks, but that means I know the group ID when issuing the link.
I don't. I am not a php coder and I would think that a so obvious and simple requirement (using Views in OG) should work out of the the box.

I thought that the default argument "Current group node from context" would guess automagically what the current group is, passing it to the view that would keep it while displaying the node list....
If it doesn't do that, I really don't figure out in which circumstance it would help.

Again, I think I really miss something: I did not found other complaints and I cannot believe than nobody uses Views with OG...

.

amitaibu’s picture

Title: Problem with OG context » Getting OG context on custom path
Status: Active » Fixed

The context is lost because you are on a custom path.
You should change your 2nd argument to be php code and use:

  // Get the node ID from the URL (e.g foo/[nid]).
  $nid = arg(1);
  // Load the node
  $node = node_load($nid);

  if ($group = og_determine_context_get_group($node)) {
    // Group node was found, so return its ID.
    return $group->nid;
  }
jvieille’s picture

Thanks a lot, but where this code should be copied to?

By the way, I am trying to use Taxonomy menu that call a view with a single argument as the term ID
(the OG Vocab handles the context, but does a weird job, not using Views, not usable for me)

jvieille’s picture

I found the way to set an argument in PHP.
So I set the second argument "Organic groups: Groups" as default with a type "PHP code" (the first stays the term ID)
That did not help much.
Now, when calling the view with the term ID argument from the group it is relevant, I am redirected to another group...

I am sorry to be so dumb, am I looking for something that nobody normally need - basically using Views in OG?

By the way, why this post has been renamed "Getting OG context on custom path"? What would be a non-custom path?

Thank you so much for your help

jvieille’s picture

Status: Fixed » Active

This is not yet fixed...
Still no way to keep context when calling a View - nothing works to date.

Thanks for help

amitaibu’s picture

set the second argument to be node: nid

jvieille’s picture

No way.

I set the following argument
1 Taxonomy: Term ID
2 Node: Nid (default argument, php code as indicated)
and path og_tags/%

When I call this path with a term id attached to a post in the group, the context is lost on the spot and the view returns nothing.

I only succeeded at getting something by inverting the 2 arguments:

1 Node: Nid (default argument, php code as indicated)
2 Taxonomy: Term ID

In this case, the view returns the correct nodes, but the context is lost

Also, setting the default argument as php with this code or selecting "Current group node from context" seems to be equivalent

jvieille’s picture

Additional thoughts after Looking again to some indications in Drupal Discussion and the issues I experiment:

1) I could manage to kee the context ONLY when calling a View from within the group main page only, setting a path tha add a tab to this page.

2) It seems IMPOSSIBLE to keep the context when calling a View from a menu item - everything discussed is not for this situation, but when the view is called from within a group node or a node in the context of a group

3) I found something here:
http://drupal.org/project/context
I don't really understand what the "context module" does, but I found this discussion which seems to be a possible solution for OG
http://drupal.org/node/689972
#13 even propose a specific module that might be what I am looking for.

Just a little bit surprised: aren't really there almost anybody using View in OG??? (except for the very specific situation of filling up the main group page)?

Am I still missing the point, or am I getting closer to a real issue?

marcp’s picture

@jvieille - For this issue, please do not bring the Context module into the equation. If you can give exact steps to reproduce the problem we'll be able to help you. Exact steps are, for instance:

1. Install Drupal 6.16
2. Install OG
3. Install Views
4. Enable views, og, og_views
5. Anything else you do between now and when the problem occurs. Keep it simple so that we get the minimum amount of work to reproduce the issue.

mxt’s picture

Subscribing, I've similar issues keeping OG context outside OG pages, in particular with Views and OGUR.

See my post:

http://drupal.org/node/742676 where yhahn suggests to resolve the issue using Spaces OG & PURL modules (I'll try in next days)

Also see:

http://drupal.org/node/759264

http://drupal.org/node/737292 and in particular http://drupal.org/node/737292#comment-2846284

MXT

jvieille’s picture

@Marcp

Scenario (1)
Setting Taxonomy menu for a group vocabulary, with a custom view (single argument term ID)
Adding a second argument as indicated everywhere using all methods (node nid, group, group from context, PHP...):
Nothing goes out, context is lost

Scenario (2)
Calling this same simple view directly from the browser, typing the path and the term Id as argument:
- Nothing goes out, context is lost
Adding the group nid as second argument:
- correct behaviour, the nodes are displayed and the context is kept - but I cannot do anything with that...

Scenario (3)
Using the Group category block, editing the taxonomy_term view by adding the second argument as mentioned above
- Does not work, context lost

I am almost giving up. What I am looking for is not that exceptional. This post might be more explicit:
http://drupal.org/node/774468

Any help would be appreciated
Thanks

marcp’s picture

Sounds like you must be using og_vocab from the 3 scenarios you mentioned -- is that right? If so, this issue belongs there.

Also, if you are able to provide exact steps to reproduce the problem ... see above ... that will help the maintainers of whatever project this pertains to. Your descriptions of the problem are fine, but without exact steps it's impossible to reproduce.

jvieille’s picture

Yes, this is all with OG Vocab

Scenario 3,
----------
the steps are the following:
- Define a vocab for a group, define some terms and tag some nodes in this group with these tags
- Enable the Group category bloc
- Everything is fine, you can browse the group nodes which are tagged on this vocabulary, keeping the current group context

Now, you are not happy with the way the nodes are listed and you wish to customize the listing of nodes.
- enable the "taxonomy_term" view which by default provides the exact same function than the Drupal core taxonomy node listing. If this would work, it will be possible to customize the node listing at will
- try again browsing from the Group category bloc
- When clicking on a term, you get the same listing as before, but you are thrown out of the group.

You are somewhat disappointed but not desperate and fervently look in the forums to learn about this "context" issue with views that seem to be addressable. Actually, there are default arguments that are supposed to pass the context to Views even if the path to calll the view is not context aware.
This is where I am stuck. Nothing succeeded to date.

Scenario 2
----------
Having failed at getting the Group category bloc working with Views, you decide to go simpler
With the same environment,
- create a simple view that list the nodes from a term
- define a first argument with Term ID and e second argument with Groups: group
This works fine, you can list the nodes for the term in the group

Now, make the second argument as default with group context from node or the PHP code that is advised from pklace to place
- try to call the view by typing its path from the group main page
- if you only type the term ID, the context is lost - meaning that the default argument does not play the game
- if you type both the term ID and the group node ID, everything is fine.

Scenario 1
- Enable Taxonomy menu for the group vocabulary, custom path to the previous View
- The taxonomy menu list correctly the terms, click on one term
- while the number of node is displayed, no node is listed on click, context is lost.

marcp’s picture

When you say:

- When clicking on a term, you get the same listing as before, but you are thrown out of the group.

what do you mean exactly? Are there blocks that are supposed to display for your group? Is the theme supposed to change? If you are talking about the theme, then #698238: Organic groups vocabulary term display does not get the group theme is a duplicate of this.

When you switch the Project for this issue to OG Vocabulary, you'll need to reset the Version and Component. It would be best to look through all the OG Vocabulary issues and search for any patches that may address this. Also, you should try the latest dev release or the version from CVS to see if it hasn't been fixed but not yet released.

jvieille’s picture

Title: Getting OG context on custom path » OG context lost with Views using term argument - e.g. Group category block with taxonomy_term
Project: Organic Groups » OG Vocabulary
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Og Views » Code
Category: support » bug

I don't play with themes, just using the standard OG Vocab Group Category block.
I just installed the latest OG Vocab dev, but no progress.

I am switching to OG Vocab, which seems more relevant.
This now looks like a bug - or a missing feature?

Yet another post on this list!!! May be if a solution is found, a couple of issue might go off...
http://drupal.org/node/605138
http://drupal.org/node/404978
http://drupal.org/node/774468
http://drupal.org/node/708912
http://drupal.org/node/763308
http://drupal.org/node/748626 (because the "post_by_term" will not be useful anymore)
http://drupal.org/node/724288 (already duplicate)
http://drupal.org/node/698238 (may be)

OG and OG Vocab are really great, if only such a (apparently) minor issue could vanish...
Thank you in advance for looking at this

jvieille’s picture

I am really lost here.
I would appreciate some help

Thanks

jvieille’s picture

Status: Active » Closed (duplicate)
greta_drupal’s picture

Having the same issue. My response and what I've tried
here: http://drupal.org/node/763308#comment-2962022