any way to embed forum or create and embed view with forum topics of the group -> into a group?
Lausch - September 18, 2007 - 03:18
| Project: | OG Forum |
| Version: | 5.x-2.0 |
| Component: | Code |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
hi guys,
any way to include the forum into the group? or use a view to embed the forum topics?
i got a snippet to get the forumID of a group, but will this help?
greets
Lausch

#1
Huh???
#2
#3
ok sorry,
any way to embed the forum into another NODE like the group node?
:-)
greets
Lausch
#4
I'm not sure. Perhaps you could explain the use that you have in mind. Do you simply want the group forum to be the front page of the group? Or do you want some kind of code that you can use in a node that will shove the forums into that spot of the node?
In the first case, you could probably just change all of your group links to point to the group forums, rather than embed the forums in the front page.
In the second case, that might be really hard and I can't think of a way off of the top of my head to do that (though it might be possible).
I would do some research into embedding one content type into another in general if I were you. Or research embedding nodes within nodes. I think there may already be some work in that area. Then report back here whatever you find.
#5
thanks for the informations,
ok i want to show the forum on my group homepage
also something like this will be good
http://www.mailfriends.com/node/530603
they use also og
greets
Lausch
#6
You could probably do this in your theme files. There is a function in og_forum (or was it forum?) that displays a forum. You could do a check in your theme to see if the page you're viewing is a group home page and if so, call that forum display function.
To check if you're on a group home page, check the node ID of the page you're on and compare to the node ID of the group via a group ID-to-node ID look up. I'm sure there are examples of that in the handbooks on Drupal.org. That is, examples of identifying the page you are on in your theme.
I can't say I'm going to add anything special for embedding forums in other pages, though views might do that once I implement that. So I'm going to mark this as closed.
#7
ok, i found a way now.
for all other that need the same, try include this at your group-theme file:
<?phpif ($page == 0) {
?>
<?php};
?>
<?php$forum = og_forum_get_forum_container($node->nid);
?>
<?phpif ($forum):
?>
<?phpprint module_invoke('og_forum', 'page', $forum);
?>
<?phpendif;
?>
<?phpendif;
?>
greets
Lausch
#8
Could you please re-write the code above? Right now, it doesn't look right. Also, it would be great if you could point out the exact place where one needs to write that code.
Thanks for your efforts. Embedding the forum will be a nice change to the way og forums work.
#9
oh yes...
sorry guys
take a look to the following code. this works 100% (tested in drupal 5.x)
<?php
$forum = og_forum_get_forum_container($node->nid);
print module_invoke('og_forum', 'page', $forum);
?>
and also you can invoke the default forum module:
<?php
$forum = og_forum_get_forum_container($node->nid);
print module_invoke('forum', 'page', $forum);
?>
greets
Lausch
#10
I knew you could do it! Good job.
#11
I tried this and it causes non-members of the group to get "access denied" on the group page. Anyone else have this problem?
Anyone know how to fix (I can't seem to find any controls to make to og forums public), or another way to show the group forum on the group home page?
#12
Due to the restrictive nature of og_forums, this seems like a logical problem to have. One of the functions being called must check for permission to view the forums. Naturally, this wouldn't allow non-members to view them. This is somewhat related to the problem of public forums discussed in another issue thread. But until I fix that, you may want to conditionally show the forums and if the user isn't authorized, show something else instead.
#13
OK thanks. Nice to know.
So in my group.tpl.php I would put an if statement, do you know what that might look like? As I understand it, the function should be IF in group and group member show forum, right? Is this in the right direction, I'm new to drupal, sorry.
<?php
if ($group) {
$forum = og_forum_get_forum_container($node->nid);
print module_invoke('og_forum', 'page', $forum);
} else {
print "Subscribe to this group to view the forum";
}
?>
#14
Any help with this? Please, group members aren't finding their forum!!!
#15
Until someone has time to work on this, I suggest you don't show the forums on the group's front page. Just post a prominent link to the group's forums instead. Sorry, gotta pay the bills.
#16
subscribing...
#17
I am working on making forums public today and tomorrow, so the conditional if thing above will not be needed (so long as you have public forums). I still am looking for help with Views integration of this module, but haven't gotten any takers. Perhaps. I'll more actively ask some Views gurus for help once I out out my next release.
#18
The mentioned code doesn't really work for me:
<?php$forum = og_forum_get_forum_container($node->nid);
print module_invoke('og_forum', 'page', $forum);
?>
It shows all forums and not just the one of the current group.
Additionally, that code gives me a page view, thus setting the page title to "Forums" etc.
Any way to get a block view instead?
#19
It seems the whole problem is getting the right forum container. Once I got this, the page title isn't overwritten and all seems to be well.
But how to get the right container?
What I want to accomplish is to have a block on every page belonging to a group that shows a list of forums belonging to that group. I've somehow got the feeling that I'm trying to reach this goal in a completely stupid way. :(
Thanks for any help.
#20
I wold like to jump on this bandwagon too. I really need a og forum view on the home page that shows the forums as well. Even a list of the top topics for each would be nice.
Are we saying that this is not currently available through Views?
A snippet can work as well but I can't make since of the discussion in this thread to apply a proper change.
#21
Since this has more discussion, this will take the place of: http://drupal.org/node/173162
#22
If someone has figured this out, I would appreciate any details that can be provided. I need the OG Forum view available on the OG home page and not through a link.
#23
I got something that may not be the solution for everyone but can be used as a starting point until there is a proper fix.
What we wanted was to have the list of forums in the right sidebar in a block in addition to a link that points at the existing forum overview.
I created a block with the following content:
<?phpif ((arg(0) == 'node') && is_numeric(arg(1))) {
$bla = arg(1);
$forum_id = db_result(db_query('SELECT tid FROM {og_term} WHERE nid = %d', $bla));
if (!$forum_id) {
$blub = db_result(db_query('SELECT group_nid FROM {og_ancestry} WHERE nid = %d', $bla));
$forum_id = db_result(db_query('SELECT tid FROM {og_term} WHERE nid = %d', $blub));
}
$link = l("Foren", "forum/". $forum_id, array("title" => "Forum Overview"));
print "<p class=\"link\">$link</p>\n";
variable_set('forum_list_sidebar', 1);
print module_invoke('og_forum', 'page', $forum_id);
variable_set('forum_list_sidebar', 0);
}
?>
Then I also added a phptemplate_og_forum_list to our template.php where I check the value of forum_list_sidebar so that I can have different looks for the sidebar and the full page overview.
Perhaps that helps?
#24
Thanks! I'll give this a try tonight. What specifically did you put in your template.php file?
#25
I put in a "function phptemplate_og_forum_list" which is more or less a copy of "theme_og_forum_list" from the og_forum module. There I check the value of forum_list_sidebar and if it is set, I put out a simpler version of the forum overview. You don't need that if you simply want the standard forum overview on your group homepage.
#26
Nath, thank you for sharing this snippet! I'm not a programmer and appreciate anything I can pick up from other people that have figured this stuff out better than I could have. Just curious, are you using the OG Forum module or just the Forum module for this?
Also, I was wondering if you knew of how to simply limit the block code to just the "Post new forum topic" link? I'm trying to figure out how to create my own control panel to replace the Group Details block and this would be a handy means.
#27
I think what you need is simply something like this:
<?phpif ((arg(0) == 'node') && is_numeric(arg(1))) {
$bla = arg(1);
$forum_id = db_result(db_query('SELECT tid FROM {og_term} WHERE nid = %d', $bla));
if (!$forum_id) {
$blub = db_result(db_query('SELECT group_nid FROM {og_ancestry} WHERE nid = %d', $bla));
$forum_id = db_result(db_query('SELECT tid FROM {og_term} WHERE nid = %d', $blub));
}
$link = l("New forum post", "node/add/forum?gids[]=". $forum_id, array("title" => "New forum post"));
print "<p class=\"link\">$link</p>\n";
}
?>
#28
Thanks. I put this in the header for my Forum view and it does display a link but it tries to use a GID that doesn't even exist. It tried to take me to GID 846. My current GID was 37.
#29
Are you using it in a page view? The code I posted only works if it is in a page belonging to an organic group.
#30
@sopia
yes i know this access denied problem but on my site i dont invoke the forum if user isnt a member.
i show you sample snippet that will not invoke the forum if user isnt a member of the group. maybe its useful for some peoples over there:
<?php $group->og_groups = og_get_subscriptions($GLOBALS['user']->uid); ?>
<?php if (isset($group->og_groups[$node->nid])) : ?>
<?php $forum = og_forum_get_forum_container($node->nid);
print module_invoke('og_forum', 'page', $forum);
?>
<?php else : ?>
<?php //what ever you want to do...
<?php endif; ?>
#31
is there any way of displaying forum topics in blocks without using og_forums?
much like http://thedailypunt.com/
#32
I am going to close this as the conversation looks to have run its course and we now have someone working on Views
integration which will provide a better solution