0

insert a parent comment reply form

i want hide the comment reply,when user click the “2 replies” button will slide the replies,after slide out the replies i also want to show a comment form that people can post a reply easily. anyone can help? Thank you so much.

1
  • no one can help?
    – younger870
    Oct 4, 2012 at 16:27

1 Answer 1

0

I don't know if it's correct way but maybe help somebody.

function theme_preprocess_node(&$variables, $hook) {

$test_pid = array(); 
$test_cid = array();   
$keys = array_keys($variables['elements']['comments']['comments']);   

foreach ($keys as $k) {
    if (!is_numeric($k)) {
      continue;
    }
$pid = $variables['elements']['comments']['comments'][$k]['#comment']->pid;
$cid = $variables['elements']['comments']['comments'][$k]['#comment']->cid;
$test_pid[] += $pid;
$test_cid[] += $cid;
$variables['elements']['comments']['comments'][$pid]['#comment']->has_children = TRUE;    
$last = $k; 
}

// find all last children in comments
$Mcomment_children= array();
foreach($test_pid as $key=>$p){
    if (in_array($p, $test_cid)) {      
         $Mcomment_children[$p] = $test_cid[$key];          
    }
  }

  foreach($Mcomment_children as $last_children){
    $variables['elements']['comments']['comments'][$last_children]['#comment']->last_children = TRUE; 
  }    
  $variables['elements']['comments']['comments'][$last]['#comment']->last = TRUE;
}

In comment template file (comment.tpl) you can close div with children last. I used display suite but it's the same.

<?php if($comment->has_children !== true): ?>
</<?php print $ds_content_wrapper ?>>
  <?php endif;?>
  <?php if($comment->last_children === true): ?>
</<?php print $ds_content_wrapper ?>>
  <?php endif;?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.