Hi All,
I know this is me being dumb and missing something, but cannot see what.
I have OG and Views 2 set-up and working. Have done this dozens of times. Both work fine individually and I ahve used both for a while. I always have issues when trying to get a view to work for OG.
So what I have done is to build it up step by step.
1. Created a view that filters the node type only. This works fine and shows all node types over the entire site.
(saved and tested working at this point)
2. Added a relationship "Organic groups: Group node (post)"
3. Set the path to "groups/%/myview" (tried og/%/myview as well)
4. Added the argument "Organic groups: Groups" with a relationship to (2)
5. Saved
6. viewed groups/group1/myview - nothing, completly blank.
So obviously I have something wrong but not sure what. I have looked at the standard OG views, various forum threads, etc. but still cannot see what I have wrong. I have seen some posts saying change the validaor and others saying leave it. At present I have the default validator, but have played with it without any luck.
Can someone please point me in the right direction?
Regards,
Nick
Comments
For what its worth, this is
For what its worth, this is my approach to displaying group posts (a custom content type for my groups) at groups/< group id >/posts:
Thanks for the reply. There
Thanks for the reply. There are only minor differences between yous and my set-up, but think you have hit the problem spot on. You noted in your path < group id >. I assume then when you want to view yours you go groups/543/posts?
If so, I think that is the issue, I want to be able to do it using the group name rather than the ID. I will check to see if it works with the group ID when I am at my dev machine. If this is the case, is there anyway to replace it with the group name rather than the ID? This is where the relationships should come in.
Thanks,
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Not entirely clear exactly
Not entirely clear exactly what you mean by "group name". This is available as an argument "Node: Title", but yes, you will probably need to pull this in via a relationship (since you are after posts in that group) and I'm not sure how special characters in the title are handled. You might want to bring in pathauto here somewhere if you use it, or your manually defined group URLs if you use them.
gpk
----
www.alexoria.co.uk
By group name, I mean the
By group name, I mean the name of the group. i.e. the title of the MAIN group node. As far as using "Node: Title" as an argument, there is no "Node: Title" in my argument list. The standard OG views allows the group name to be used (i.e. groups/group1), so it is obviously possible.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Almost cracked it. This is
Almost cracked it. This is what I have:
1. Relationships set to - - Organic groups: Group node (post)
2. Arguments:
a) Argument - - Node: Title (Now that I have found it!!!)
b) Relationship - Group Node (post)
c) Case - lower case
d) Case in path - lower case
e) Transform spaces to dashes in URL - true (i.e. ticked)
3. Fields - whatever is needed...
4. Filters - Node Type = "whatever" - whichever node type is required.
It works, sort of. It does display what I expect it to, however, I loose all of the groups blocks so somewhere/how I am loosing the connection with the group. So now the problem is how do I get that back? OR what have I done to remove it? Obviously another setting in the views somewhere.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
subcribing, thanks for
subcribing,
thanks for sharing your journey on implementing this.
sorry, i can't offer a better understanding of when the og blocks sense the og_context
izzy
Hi, No problem. I know it is
Hi,
No problem. I know it is something really simple, just find it frustrating it is not better documented or easier to find. Will keep everyone posted on this.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
>I know it is something
>I know it is something really simple
It may be .. or it may not be quite that simple. Looks like OG has not managed to work out the "group context" (i.e. the active/related group). I'm looking at a View I have which lists content from a specified group and I'm quite impressed that OG has worked out the group context and is showing the admin block for the group in question. Probably it managed because the group nid is the argument, so when the OG argument handler fired it also "set" the group context.
I think the catch with what you are trying to do is that you are bringing in the OG stuff via a relationship, so the code to set the OG context has not fired. You might have to do it by hand somehow, in some PHP code that runs during building or rendering of the View. See http://drupalcode.org/viewvc/drupal/contributions/modules/og/og.module?a....
http://drupal.org/project/views_customfield would be one way of injecting the code, though the field would potentially "run" for each result in the View. Perhaps someone can suggest a better way.
gpk
----
www.alexoria.co.uk
Hi, At least your thinking
Hi,
At least your thinking the same as me, gives me some reassurance it is not something stupid I have done. I did look at adding some PHP code, but not sure what or where to put it. I am sure I read about relationships being able to do this, but cannot remember or find where I saw that. Anyway, will keep digging.
Thanks for the help and pointers.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
ahh, you want to have
ahh, you want to have groups/mygroupname/view...
while i didnt go that route for group content, i did do this for user views... for example, i have a path for the current users bookmarks like users/< user name >/bookmarks, which displays the custom bookmarks view for that user...
to accomplish this, i went a slightly different route using a view argument...
I havent tested it myself, but you could try something similar for your group URLs, so even if something is group/groupname/view, it would be interpreted as group/groupid/view... make sense?
Not sure how as the OG stuff
Not sure how as the OG stuff only allows for the ID. However, it may be possible using the node title. Will have a play.
Cheers,
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Unfortunatly the options to
Unfortunatly the options to do that with groups is not there. Only Node ID's. The only other option that I know will work is to use node ID's and create an alias, but having to do that for each group would become a right pain.
I can see what the problem is, but not what or where...
So to recap, what we are aiming for is a view to be used with OG where you can use in place of the group ID in the path argument.
Cheers
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
I think the approach I
I think the approach I suggested here http://drupal.org/node/650178#comment-2336484 should work but it would be a bit tidier if you could get the PHP (i.e. og_set_group_context($node)) to run from say the View footer. However I don't know how to access the View object from PHP code in the footer and hence get a hold the node object ... you would have to investigate the Views API to find the right function to call.
Another approach might be to use an Attachment display whose sole purpose is to set the group context. Probably I'd use Views Custom Field and have done with it. :)
gpk
----
www.alexoria.co.uk
Hi gpk, I am looing into
Hi gpk,
I am looing into that. I was hoping that there would be a simple way. Is this something that needs to be raised and integrated as a feature into OG or Views? I know other people have raised this very problem before and none, to my knowledged, have published a working solution.
Cheers,
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
>Is this something that needs
>Is this something that needs to be raised and integrated as a feature into OG or Views
Without getting too intellectually involved (sorry, pressures of time!) it's not immediately clear to me "where" (i.e. Views or OG) there is a feature that could usefully be added. Perhaps OG needs an argument validator a bit like Users have? One snag I can see - there is no requirement for node titles to be unique, so you could potentially end up with a group that can't have a Views listing generated for it in this way.
Perhaps pathauto would be a way through, so that the group itself and the Views listings could use the same URL. There are ways of bulk generating URLs for existng content.
gpk
----
www.alexoria.co.uk
Subscribing
Trying to the same thing, very frustrating!!
Hi gpk, That was my issue as
Hi gpk,
That was my issue as well, lack of time! Anyway, what I am now going to do is go back to basics. That is get a view working with the ID and just run with that until I have more time to deal with putting a name in. I didn't really want to go with pathauto, I know it would work but is an extra hassle and another thing to go wrong.
Anyway, like I said, I am going to go back to basics, then try moving forward to using the group name. I have started to delve into the code/API so I think I can possibly see a way of adding a validator in, but will require time that I cannot spare at present. There is a table somewhere that must store the GROUP NODE for each group, maybe a way forward.
Anyway, will keep everyone posted.
Thanks for the help, much appreciated.
Regards,
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
>I have started to delve into
>I have started to delve into the code/API so I think I can possibly see a way of adding a validator in
Presumably you have checked the OG issue queue? Probably worth opening if feature request if there isn't one already so that others can also chip in with code/suggestions.
I'd compare the existing OG validator with that for user.module (which is bundled with Views) to see how usernames are handled.
>There is a table somewhere that must store the GROUP NODE for each group, maybe a way forward.
Well yes, {node} ;)
Also {og} stores the additional info about groups.
You shouldn't have to manipulate those directly though - usually everything can be done via the API functions provided by core and the relevant modules.
Actually for now if I were you I'd probably just do it using an Attachment display, and look upon it as an opportunity to work out what on earth it is that they do!!!
gpk
----
www.alexoria.co.uk
Hi gpk, I will open it as a
Hi gpk,
I will open it as a feature request in the queue, but I wanted to have a look at how plausable this is and wait a week or so until I have a bit more time to start tha ball rolling.
Yes, it was the {og} table I was referring to. I always look at a table first and then the API. I know, a funny way of working but it works for me. And yes, will be looking at the username validator information/code.
I would like to thank you for the help and pointers, at least I know it is not me missing something, and will hopefuly let me code something (a new feature) that can be put back into Drupal to help others.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
_
Just a guess-- but what about http://drupalcontrib.org/api/function/og_set_group_context/6 in the view header or footer (or template file for that matter)?
Hi WorldFallz, I did look at
Hi WorldFallz,
I did look at that, I believe it was mentioned in on of the previous comments. I could not get it to work, but do need to go back and try that again, when I have a clear head. I think it would have to be done in a template though as, correct me if I am wrong, you do not have access to all the node/php values in the header and footer of a view.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
_
Yep I think you're right-- it will need to go in the template file.
Hi All, Using comments made
Hi All,
Using comments made here, I have progressed this one stage further. It was suggested twice about using the "Views Custom Fields" and "Attachment Display", with the original set-up (see initial post), I think I have a partial solution. Still needs work but here is what I have.
Addint an attachment, in that attachment I have added a custom field (PHP). The code added is:
So this loads the group node and then set's the group context. The 906 is the group ID for one of my groups. This does indeed set the group context perfectly. What is needed now is for a way to find the ID rather than hard wiring it. Noting, as mentioned previously that if we use the node title, we must put extra checks in place ( several nodes may have the same title). Shouldn't be too much of a problem if we make a few assumptions:
1. Group nodes are their own content type
2. Groups will never have the same title (I know it is possible)
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
>a way to find the ID rather
>a way to find the ID rather than hard wiring it
Since your view type is Node rather than Group post you might just be able to apply the argument and relationship logic again but go for the group node rather than the posts in the group. There will only ever be one result ... Add the nid as a field, then add the custom (PHP) field after it and the nid will be available to the PHP code (install devel.module and try dsm(get_defined(vars)); if you get stuck).
Good luck!
gpk
----
www.alexoria.co.uk
Hi gpk, Thanks for that. I
Hi gpk,
Thanks for that. I had just started to look at that as you posted. I think I have it but need to do more testing. The code I have is:
I am off now, but will finish testing on Sat/Sun. Once I am happy it does work as intended, I will write up and post the solution.
Once again, thanks for the help, you are a gem.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
>dsm(get_defined(vars)); Ooop
>dsm(get_defined(vars));
Ooops, finger trouble, should have read
dsm(get_defined_vars());gpk
----
www.alexoria.co.uk
Hi, I finally got this
Hi,
I finally got this working, although it is rather messey and probably is not the best way to do it. There are lots of other issues as well, such as post being in multiple groups, etc. Only a minor thing, but I ahve ignored that for the time being. I did try what you noted, but kept getting no results when changing the node type in the filter. Anyway, again starting with a working view (see first post) what I have done is:
1. Add in an attachment view
2. In the attachment:
a) Remove all the fields (MAKE SURE YOU OVERRIDE DEFAULTS)
b) Add "Node: NID" and ensure it has a relationship to "Group node (post)" - this will link it back to the primary group node
c) Add a customfield (PHP TYPE) with the code:
d) change "Items to display" to 1 (MAKE SURE YOU OVERRIDE DEFAULTS)
3. Save it and you are done...
Not a perfect solution, but it works. Does have some flaws, i.e. it assumes the first node filtered belongs to the correct group, doesn't take into account a post may belong to multiple groups, etc.
I am now going to go and use the group ID as the argument rather than the name as a stop gap, it works, is the default and more importantly, I have not got a lot of time to spare and need to move forward. However, I will continue to work on this issue, and may look to see if I can add such an option into the Views system itself (would benifit more people but will take much longer).
Again, thanks for the help everyone.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Just to check - is your View
Just to check - is your View of type Node or Group post?
gpk
----
www.alexoria.co.uk
Hi gpk, If you are referring
Hi gpk,
If you are referring to the "View Type" when you create the view, I only have "Node", there is no "Group". I may be misinterpreting what you are asking, if so I appologise.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
I *am* referring to that, you
I *am* referring to that :) , you should have a list of options when you create the View, including Node at the top and Group posts 2nd or 3rd down.
Assuming it is of type Node you should be able to modify your Attachment view so that it picks up the group node via the argument rather than a post that might potentially be in multiple groups...
gpk
----
www.alexoria.co.uk
Hi gpk, There is definatly no
Hi gpk,
There is definatly no "Group post" on my page when I create a new view. I am using the latest OG and Views releases (not Dev). I ahve tried various configurations with the argument, none were sucessful, but am still playing with it.
Cheers,
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Oh I see what you mean, that
Oh I see what you mean, that option was removed in 6.x-2.x (I'm still running 1.x on my live site because of a couple of unresolved regressions).
The good news is that you should be able to get the attachment View to work properly (i.e. not relying on a group post being in the "right group"). You might need to override the default View arguments, then remove existing arguments and add a new one on Node -> Title, with basic validation (important! since otherwise you will get restricted to nids). If you want you can then (of course) filter on Group node types/change other settings as necessary.
gpk
----
www.alexoria.co.uk
Tried, tried and tried again
..tried following this to the letter, without success. I must be doing something fundementally wrong!
You say "Anyway, again starting with a working view (see first post) what I have done is:"
Eh, post 1 wasn't working!
Here's what I did:
Added a view of type node: (no such thing as a view type Group post gpk!)
Post 1 says "1. Created a view that filters the node type only. This works fine and shows all node types over the entire site.(saved and tested working at this point)" Not entirely clear to me!
Does that mean a node view with a filter on the content type for Group Posts?
Step 3 in Post 1 says "Set the path to "groups/%/myview" (tried og/%/myview as well)"
I take it you must add a page view prior to this step? Again not obvious!
Anything wrong with the above? If not the I am ready to proceed to your recipe. If all is successful, say I have a table in og_php_ron for a particular group showing group post titles, what should be the format of the link to get the detail view of the post?
Oh man, this is confusing!
Hi ludo1960, Confusing, you
Hi ludo1960,
Confusing, you aint kidding. When I set out to do this I thought i would be easy. Some one did say (elsewhere) jsut use url_alter and sub_path_alter (not sure of the exact name of the latter) but nothing. Anyway what I have done, from scratch is (NOTE YOU ALSO NEED Views Custom Field module installed):
1. Create a view (node type).
2. Add a page display
3. Set the path to "groups/%/whatever"
4. Add a relationship - "Organic groups: Group node (post)"
5. Add an argument
5A. Add an argument - "Node Title"
5B. Set the relationship of the argument to "Group node (post)"
5C. Set "CASE" and "Case in path: " to "Lower case"
5D. Put a tick in the "Transform spaces to dashes in URL" box.
6. Add the fields and filters that you need for your view. Anything you like...
7. Add in an attachment view
8. In the attachment:
a) Remove all the fields (MAKE SURE YOU OVERRIDE DEFAULTS)
b) Add "Node: NID" and ensure it has a relationship to "Group node (post)" - this will link it back to the primary group node
c) Add a customfield (PHP TYPE) with the code:
d) change "Items to display" to 1 (MAKE SURE YOU OVERRIDE DEFAULTS)
9. Save it and you are done...
That is all I ahve. I will post again in a bit with the export from my view, will allow you then just to import it directly and use that as a base. I would love for there to be an easier method, perhaps there is and we have all missed it!
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
The exported view
As promised, the exported view:
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Cheers..
..for that, even I can follow that!
The missing bit is the link from the og_ghp_ron master view to the group post, any ideas?
Cheers again!
Hi, Excellent. Not sure what
Hi,
Excellent. Not sure what you mean, I did not have any link on og_ghp_ron. What I did do was create a menu item linking to my view, using the OG Menu module.
Let me know if that is what you are talking about or not...
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Thanks again..
.. what I intended to do with this view you created was to have a link from the group home page (og_ghp_ron) (that shows all posts in that group), then on say the title of each post would be a link to the new view. So the million dollar question is how to create that link? Does that make sense? Or does that open yet another can of worms?
Ludo...
Hi, Corrct me if I have
Hi,
Corrct me if I have misunderstoof, but you want the titleview of all nodes on the standard group homepage to link to a view instead of the node?
If so, (I have not tested this so no gaurantees it is right, let alone work):
1. create a clone of "og_ghp_ron" (NOTE the clone name must start with og_ghp_ )
2. Change the row style to node
3. Add in any fields you need
4. On the title node, enable "Output this field as a link" and set the options required.
5. Save the view
6. change the OG home page to the view you just created (admin/og/og?destination=admin%2Fog)
Give that a try. If not, am not too sure...
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
You are..
..indeed correct....
4. On the title node, enable "Output this field as a link" and set the options required.
That is the million dollar question, the "Output this field as a link" should link to the new view.
What is the correct syntax for this link?
Hi, Good question, I don't
Hi,
Good question, I don't have a good answer though! Afraid I am not too sure about that, if you can link path auto into it or not. There is another option just above "re-write output" which may let you use php to work the path used for linking.
Nick
------------oOo----------------------
Nick Young (www.nickbits.co.uk)
Subscribe - I wish there were
Subscribe - I wish there were an easy tie-in for this :-/
__________________
Personal site: www.jeffgeerling.com
Subscribing.
Subscribing.