Insert forum thread and comments

zewa - March 6, 2009 - 15:51
Project:InsertNode
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

hello ...

I searched for a possibility to include a forum discussion beneath one of my pages, and came around
this Module today.

Its a great Idea and helps me much. But for my special need I edited the script a bit and want to share
it now with you.

Sry im quite a noobie to this patch thing, so ill just place paste the code here.

Replace the preg_replace text with this here:
case "process":
    return preg_replace_callback('/\[node:([^\s\]]+)(?:\s+(body|teaser|link|collapsible|collapsed|forum))?\]/', '_insert_node_replacer', $text);

this will add a new option 'forum'


now in the function _insert_node_replacer
insert inside the switch-case statement following:

case 'forum':
        $output = theme('node', $node);
        echo $node->nid;
        $result = db_query('SELECT * FROM {comments} WHERE nid = '.$node->nid);
        while ($comment = db_fetch_object($result)) {
          $output .= theme('comment_flat_expanded', $comment, $node);
        }
        return $output;

that should now output your forum node + the comments.
What still needs to be done is to intend the comments as they are in the forum. Currently
they are all flat.
Also the possibility to sort them would come in handy as a config part in drupal - settings

Greetings
Zewa

#1

zewa - March 6, 2009 - 16:14

one issue comes up with caching.

As it seems that the inserted nodes are cached other ways
the forum included is not up to date ...

ill check this maybe someone other got an idea too.

Greetings
Zewa

#2

AlexisWilke - March 7, 2009 - 08:17
Status:needs work» fixed

Hi Zewa,

Not a bad idea. I started with your patch, but then changed the whole scheme.

You will have a new module available in the -dev. Please, let me know whether this works for you or not. Make sure to change the status back to "active". If you do not have any problem (you or others) then I will publish this new version within a week or so.

It fixes the caching problem.

The flat/thread and expanded/collapsed selection defined in the node type is used. Unfortunately, there isn't an easy to use solution to make it a parameter selection instead... (right now, all the turn around solutions are ugly.)

Let me know if you have problems with this newer version.

Please, see the project page for more info.

Thank you.
Alexis Wilke

#3

zewa - March 7, 2009 - 10:00

oh wow ... nice ... found 10 minutes ago the caching problem myself ... but its great that you like that
idea and implemented it yourself.

I'll have a look right now and tell you about it.

EDIT:
Mmhm either I missed something or the changes arent updated into the dev version.

Greetings
Zewa

#4

zewa - March 7, 2009 - 10:22

OK sry as said Im quite a nooby to the whole Drupal scene, but finally I found out what you meant with -dev ... the cvs ^^

I tested the (strangly called "Dead file"), and it makes my dreams come true :)
Thats exactly what I wanted to create.

Well for the ultra feeling of overwhelming power, it would be great if the answer/replying of one comment
wouldnt redirect me aftwerwards to the forums, but i think this would need some hacks of the existing module comment
which is not sooo good.

Anyway. your update works at glance and thanks again for your that great feature.

Greetings
Zewa

#5

AlexisWilke - March 8, 2009 - 06:47

zewa,

Actually, the -dev version is regenerated only once every 12 hours. So downloading the -dev too soon would not give you the right files. Getting the files from the CVS, however, is immediately correct. 8-)

Thank you.
Alexis Wilke

#6

zewa - March 8, 2009 - 07:53

Thx ... with every challenge i learn a bit more :)

#7

System Message - March 22, 2009 - 08:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.