It would be great, for those of us who have created a forum category for each OG, to be able to specify that, for example, a Discuss This! link on a 'Page' in group 'Marketing' would add a topic to the 'Marketing' forum but a similar link on a 'Page' in group 'Sales' would add a topic to the 'Sales' forum.

Even if there were a restriction on naming - like the Forum name had to match the OG name - that would be OK. I have been able to add links on the OG Details block in such a manner that point to the group's forum using the hook_og_links_alter function like this:

    $gid = og_get_group_context();
    //Add the forum link
    $title = $gid->title;
    $term = taxonomy_get_term_by_name($title);
    $forum_id = $term[0]->tid;
    $links['forum'] = l(t('Team forum'), 'forum/' . $forum_id);

I haven't looked at this module's code, but if it's a simple matter of formatting the Discuss this! link similarly, then I'll make the patch and post it here. If it will take more than that, I may not get to it soon, but will probably still try to figure it out when I can get a chance.

Comments

AlexisWilke’s picture

Constantine,

Right... the link at the bottom of the pages does not directly point to a forum. It actually points to an existing forum post where you can reply to existing comments, or points to discussthis/new/{$node->nid}.

The forum post is actually created by discussthis. The users only create comments. The first comment is handled by discussthis so we avoid creating a new forum post if the user is to cancel the creation of a comment.

You will find the logic inside discussthis_create_form_submit() in discussthis.module around line 916. That function calls:

$discussthis_forum = _discussthis_get_forum($node->nid, $node->type);

which I guess is what you'd want to transform based on the node being commented (you get the nid and type since that's all I need for now, we may want to pass $node as a whole instead if you need more info about the node.)

Thank you.
Alexis Wilke

rconstantine’s picture

OK. So I downloaded the module and checked out the code. It isn't as simple as I had hoped to change it, but shouldn't be too bad. I don't have time today, but maybe later this week. Here is what I think needs to be done...

1) Add an option on the term selector <based on group>.
2) Change the _discussthis_get_forum function to return -1 if we have selected the above option.
3) Adjust the check in the discussthis_link that uses the above function to check if the result is 0 or less than -1.
4) If the result is -1, then use taxonomy_get_term_by_name, or our own custom function (maybe that specifies the vocabulary) to search for the tid of the group's forum.
5) Adjust the hook_menu to simply add another wildcard in argument 3 for the category tid on both discussthis/new/% and discussthis/create/%, I think this can be done just by adding to the page_arguments without actually doing another % in the path. I think that makes it so that NULL can be allowed in that 3rd spot - i.e. it won't be required. That way we are backwards compatible.
6) Adjust discussthis_new to handle the new argument: function discussthis_new($nid, $tid = NULL).
7) Adjust discussthis_create_form to handle the new argument: function discussthis_create_form($form_state, $nid, $tid = NULL).

I think that's it. Essentially, we search for the place to put the new node only on the first time. Participate links and functions should work the same as they did before I think.

Hopefully I'll get to this soon.

Obviously, this isn't integration with the og_forum module.

AlexisWilke’s picture

I suppose you posted your own reply without reading #1 first. It could be a good idea to allow for a specific forum to be specified on the link instead. That way, it would indeed not be specific to the OG system. Then we can have only one small specialization for OG and could add more as time passes.

On the other hand, defining the tid based on OG from within the _discussthis_get_forum() function would probably suffice and be a lot simpler. I guess there should be a flag in the settings to determine whether the OG logic should take over or not.

Thank you.
Alexis

rconstantine’s picture

I think I was writing #2 as you did #1 given the proximity in time and my tendency to take forever writing anything.

Anyway, I can see the possibility of moving all new logic into the _discussthis_get_forum function. What I didn't understand was your first paragraph in #3. Unless there is an automatic way to establish different TIDs, like based on OG, how else would different ones be specified?

AlexisWilke’s picture

Good point. Maybe we ought to have a hook callback inside that function so a user can create his/her own code to generate the tid. That way your hook could use the code as shown in #1. Does that sound better? The hook return value is FALSE or NULL by default, so we could check if !empty(), return that value, if empty() use the default behavior.

Thank you.
Alexis

rconstantine’s picture

Good idea. If I can get to this, I'll try and do it that way.

dom.’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Module maintainer has changed. I'm closing this issue after years of inactivity, please open a new issue if needed.