By seth97 on
It is hard to understand how arguments are defined in Views.
I want to create a view for organic groups. The view should be available in all organic groups where a specific content type (my_content_type) is used.
So, the url should be: 'node/$arg/my_content_type'.
Where '$arg' should be all nid:s for the organic groups that are using 'my_content_type'.
Let's say that I know that 'my_content_type' is used in groups nid = 85 and 86. So I should get a list of all 'my_content_type' in the groups if I go to:
'node/85/my_content_type', and to: 'node/86/my_content_type'
How do I define $arg? Both with 'Argument Type' and 'Argument Handling Code'?
Thanks,
Seth
Comments
Don't show empty views as a menu tab in groups
Another way would be if the view is empty (no posts of 'my_content_type' in the current group), then the view should not turn up as a menu in the current group.
/Seth
Subscribing in case anyone
Subscribing in case anyone explains. I've never had the time to understand views arguments beyond passing a taxonomy term. For the sort of thing you are doing my approach is usually to use a joined database query to pull out to determine which content types are being used by the group in question and then manually linking to or calling the view using a conditional (if required) in the tpl.php file.
override
Hi!
jimbop, have you done an override of the group page with a ....tpl.php file?
I have done overrides for the user profile, but not for displaying OG group home pages.
Can you share your override with me?
Thanks!
Seth
I haven't yet but will have
I haven't yet but will have a go within a couple of days. If you are using a custom CCK content type as OG home page (in OG settings) then you should be able to override as for any other content type. I generally use the following method:
1. copy node.tpl.php and rename to node-type.tpl.php (eg node-record.tpl.php for a cck type called 'record')
2. either add your custom text before the
print $contentline (outputs all the CCK fields as per normal). In your case this would probably query the db to check whether the "specific content type (my_content_type) is used" --> can you be more specific? Do you mean that you are referencing another node or what?3. if you don't want to use the standard print $content you can print individual fields by
print content_format('field_fieldname', $field_fieldname[0], 'default', $node);(see http://drupal.org/node/92382 for more detail)Let me know if this is the sort of thing you're after and I can post more details if required. I'm still not clear as to what you mean "for the organic groups that are using 'my_content_type'"...
I will have a look
Hi jimbop!
I will have a look at your suggestions! thanks!
About:
"for the organic groups that are using 'my_content_type'"...
I am using OG content type admin:
http://drupal.org/project/og_content_type_admin
So, different content types are used in different groups. Since I have like 10 different content types I don't want all groups to have access to all (it gets too messy on the group home page).
That's why I want to use Views to display content type that is used only in that specific group.
The content type 'group' specifies how the group home page is displayed. This is a very simple content type (title, body, image). I am aiming to do the override for 'group'.
The other content types (that are controlled by 'OG content type admin') are content types that the group members can submit with in the group, different types of posts within the group.
I'll let you know my progress....
/Seth
Also, see
Also, see http://drupal.org/node/48816 for how to manually insert a view page or block.
Thanks!
Hi jimbop!
Thanks for your help!
I think that solves my problem!
My plan:
*I will do the override for the display of the group home page. (Your suggestion seems to work fine for me!)
*Then I will check which content types that 'OG content type admin' has allowed in the current group. (I don't know how yet....)
*If the content type 'my_content_type' is activated in the group then I will print something like:
href="/My_Site/node/247/my_content_type">List of my_content_type,
which will give a link to the 'view' that lists all posts in the current group of the content type 'my_content_type'.
Thanks!
Seth
deleted
deleted
Very nice!
"how to manually insert a view page"
Very nice jimbop!
Thanks!
this is how I solved it
I had two aims:
1) Have different messages on the group homepage depending on if the user is a member or not in the group.
2) Show a link to a View listing all posts of a specific content type, if the content type is used in the group.
I am using Organic Groups and Content Type Administration by Organic Group: http://drupal.org/project/og_content_type_admin
1) I have a simple content type for OG called 'group', which is the homepage for each group. I created 3 CCK fields:
field_text_member (text field for members)
field_text_non_member (text field for non-members)
field_diff_message_non_members (Check boxes/radio buttons, with the values: 'No - same message for everyone' or 'Yes - special message for non-members')
All display options for all 3 fields were chosen to 'Hidden', since I will print them out in the override instead.
I did the 'group' display override as explained above: http://drupal.org/node/214340#comment-706607
Before 'print $content' in 'node-group.tpl.php' I inserted the following code:
2) I have done a 'View' for each content type that will list all submitted posts in the current group for that specific content type. The url is: 'node/$group/ContentTypeExample', where $group is the current group. I then want to show a link to this View if the group manager has decided to activate the content type in the group (otherwise there will not be any posts of that content type in the group).
Here is how I did it: http://drupal.org/node/229327#comment-764969
Another way to do this would be to check if the View contains any posts, if it contains posts then print a link to the View.
Hope that helps, if someone is interested....
/Seth
subscribing- og solution
subscribing
http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.