Skip to main content
answered to second part of question
Source Link
Kojo
  • 3.5k
  • 4
  • 33
  • 62

You can copy the file called comment.tpl.php from the folder where base AT theme is located (something like adaptivetheme\at_core\templates) and paste it into sites\all\themes\YOUR_AT_SUBTHEME\templates.

Assuming recipes is the machine name of your content type, you can also name it comment--recipes.tpl.php if you want to theme specifically comments for recipes.

Then with the help of comment.tpl.php API (you can also find a lot of information in the php file itself), you can edit the way your comments will be displayed.

I.e instead of

print render($content);

You can display specific fields :

print render($content['comment_body']);

or hide specific fields

hide($content['author']);
print render($content);

To alter the form itself, you need to use hook_form_alter() in a custom module.

/**
 * Implements hook_form_alter().
 */
function YOUR_CUSTOM_MODULE_form_alter(&$form, &$form_state, $form_id) {
  //get the form id
  drupal_set_message("Form ID is : " . $form_id);
  $print = '<pre>' . print_r($form, TRUE) . '</pre>';
  drupal_set_message($print);

  switch($form_id){
    case 'YOUR_COMMENT_FORM_ID':
      //alter your form (with the complete correct fields names)
      $form['YOUR_FIELD_YOUR_NAME']['#type'] = 'hidden';
      $form['YOUR_FIELD_SUBMIT']['#value'] = t('Post comment');
    break;
  }
}

You can also use dpm($form) if you have Devel installed, or make a

$print = '<pre>' . print_r($form, TRUE) . '</pre>';
drupal_set_message($print);

in order to retrieve the exact form fields

You can copy the file called comment.tpl.php from the folder where base AT theme is located (something like adaptivetheme\at_core\templates) and paste it into sites\all\themes\YOUR_AT_SUBTHEME\templates.

Assuming recipes is the machine name of your content type, you can also name it comment--recipes.tpl.php if you want to theme specifically comments for recipes.

Then with the help of comment.tpl.php API (you can also find a lot of information in the php file itself), you can edit the way your comments will be displayed.

I.e instead of

print render($content);

You can display specific fields :

print render($content['comment_body']);

or hide specific fields

hide($content['author']);
print render($content);

You can copy the file called comment.tpl.php from the folder where base AT theme is located (something like adaptivetheme\at_core\templates) and paste it into sites\all\themes\YOUR_AT_SUBTHEME\templates.

Assuming recipes is the machine name of your content type, you can also name it comment--recipes.tpl.php if you want to theme specifically comments for recipes.

Then with the help of comment.tpl.php API (you can also find a lot of information in the php file itself), you can edit the way your comments will be displayed.

I.e instead of

print render($content);

You can display specific fields :

print render($content['comment_body']);

or hide specific fields

hide($content['author']);
print render($content);

To alter the form itself, you need to use hook_form_alter() in a custom module.

/**
 * Implements hook_form_alter().
 */
function YOUR_CUSTOM_MODULE_form_alter(&$form, &$form_state, $form_id) {
  //get the form id
  drupal_set_message("Form ID is : " . $form_id);
  $print = '<pre>' . print_r($form, TRUE) . '</pre>';
  drupal_set_message($print);

  switch($form_id){
    case 'YOUR_COMMENT_FORM_ID':
      //alter your form (with the complete correct fields names)
      $form['YOUR_FIELD_YOUR_NAME']['#type'] = 'hidden';
      $form['YOUR_FIELD_SUBMIT']['#value'] = t('Post comment');
    break;
  }
}

You can also use dpm($form) if you have Devel installed, or make a

$print = '<pre>' . print_r($form, TRUE) . '</pre>';
drupal_set_message($print);

in order to retrieve the exact form fields

Source Link
Kojo
  • 3.5k
  • 4
  • 33
  • 62

You can copy the file called comment.tpl.php from the folder where base AT theme is located (something like adaptivetheme\at_core\templates) and paste it into sites\all\themes\YOUR_AT_SUBTHEME\templates.

Assuming recipes is the machine name of your content type, you can also name it comment--recipes.tpl.php if you want to theme specifically comments for recipes.

Then with the help of comment.tpl.php API (you can also find a lot of information in the php file itself), you can edit the way your comments will be displayed.

I.e instead of

print render($content);

You can display specific fields :

print render($content['comment_body']);

or hide specific fields

hide($content['author']);
print render($content);