Comments

tom_o_t’s picture

Assigned: Unassigned » tom_o_t

Assigning task to self

tom_o_t’s picture

Status: Active » Needs review
StatusFileSize
new3.24 KB

Attached is a patch with my initial pass at this functionality. Includes a patch to nodecomment.module and nodecomment.view_default.inc

The topic review only shows up when comments are being added on a separate page to the forum (configured at /admin/content/node-type/forum in the comment settings section).

still todo:

move some of the html code that wraps the "topic review" into a theming function
add css to the div containing the topic review to set a height: 200px; and overflow-y: scroll;

I'd love to hear feedback on what I have so far though.

merlinofchaos’s picture

Code style: Using tabs instead of spaces.

+		  if ($view_name) {
+		    $review_output .= views_embed_view($view_name, 'nodecomment_comments_2', $parent->nid);
+		  }

While our default will obviously include this display, we should probably check to see if this display exists. If not, we should fallback (maybe to displaying nothing). If the display does not exist, I think this will throw an error.

Also note that if we're responding directly to the post rather than another topic, I believe we'll be displaying the main forum post twice:

           $parent_nid = is_numeric(arg(4)) ? arg(4) : arg(3);
           $target = node_load($parent_nid);
           $form['#prefix'] .= node_view($target);
<em>// ...</em>
+		  $forum_nid = arg(3);
+		  $target = node_load($forum_nid);
+		  $review_output .= node_view($target);
+  $handler->override_option('sorts', array(
+    'created' => array(
+      'id' => 'created',
+      'table' => 'node',
+      'field' => 'created',
+    ),
+  ));

Why is a sort being added to the defaults? (Or maybe that's to the first display) -- either way, the display adds the sort automatically based upon comment settings so that it can work with/without threading. This will override that, I believe.

tom_o_t’s picture

Thanks for the feedback.

I'll tidy up the code and add a setting to turn on the 'topic review'. If enabled, the topic review will remove the duplicate node that's displayed above the comment form (the node that's being replied to).

tom_o_t’s picture

StatusFileSize
new5.48 KB

Here's a second attempt at the patch:

  • replaced tabs with spaces and ran the coder module on my changes (and trying to wrestle Eclipse into not losing my settings)
  • added a check for the view display - if missing it just shows the initial forum post
  • added an option in the comment settings for each content type to turn on 'topic review' - if this is done then the node being replied to is removed from above the comment form and the topic review is displayed underneath in reverse chronological order
  • the sort is being added to the 'topic review' display of the view, which is a simplified flat display of nodes in reverse order
  • output of the topic review is in a separate theme function

Let me know what you think. If it's OK then I'll commit this add a setting to DruBB so that 'topic review' is enabled by default for the forum content type.

merlinofchaos’s picture

+ * Topic Review is disabled
+ */
+define('NODECOMMENT_TOPIC_REVIEW_DISABLED', 0);

While minor, I don't see much value in a define for a boolean value.

+    $form['comment']['topic_review'] = array(

The setting should be node_comment_topic_review for namespace reasons.

Also need to check hook_node_type_info (or whatever that's called) which responds to changes in node type info to make sure our variables are moved or deleted as necessary.

Otherwise, this looks good!

tom_o_t’s picture

StatusFileSize
new5.83 KB

Okay - here it is

  • Removed unnecessary defines
  • fixed namespace for form and variable_set()
  • added to hook_node_type() to delete/rename variables in response to changes in node type
merlinofchaos’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)
Issue tags: -DruBB topic/reply post form

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