Hello! Great thanks for this needed new module!

There is 2 troubles using Comment fields:

I turned on the comment_field_example module and added in comment_fields_example.module 2 my arrays of fields (save 'birthday' and 'feeling' there were 4 fields). After I put only my 2 vars (no 'birthday' and 'feeling') into file comment-mynodetype.tpl.php template and put it in my theme directory, and after I saw:

1. All the same there was all 4 fields in comment form, although I didn't add 'birthday' and 'feeling' field in comment-mynodetype.tpl.php.

2. All my node types has the same fields (4 fields), although I created only comment-mynodetype.tpl.php.

I tried to delete comment.tpl.php from comment_example module directory but nothing had been changed.

Please, say me - if #1 works as designed I can create new module for different fields in different node types but how to be with #2? Does it works as designed too. If so, this issue should be feature request.

Great Thanks for help!

Comments

aklump’s picture

Hi kaztur, thanks for your questions...

1) I would suggest copying the example module to sites/all/modules/custom/ where you can rename it and modify it as needed. You should replace the current code in comment_fields_example_comment_fields_info_alter with your own. All the definitions there will appear in your tpls.

2) I think you need to replace $info['all'] with the $info[NODE_TYPE] and you will see the fields only on the intended node types.

I added more explanation to the files in version 6.x-1.1, which you can download and try to use now instead of 1.0. It will also address the other issue you found.

Thanks!
aklump

aklump’s picture

Status: Active » Closed (works as designed)
kaztur’s picture

aklump, Great Thanks for Your answer! It's rare when maintainers answer so fastly.

The error in other issue has gone and I understooden how to divide comment fields via content types.

But now there's nothing instead of value in the fields (in both content types I created fields for).

I've done such changes (sorry for my laziness, but I do it in Yout module :) )

1. comment_fields_example.module:

$info['kazan_hotel'] = array(
	'period' => array(
      '#title' => t('Travel period'),
      '#type' => 'textfield',
	  '#weight' => -5000
	  ),
	'from' => array(
      '#title' => t('Your city'),
      '#type' => 'textfield',
	  '#weight' => -4500
      ),
	);
  
  $info['firm'] = array(
	'contname' => array(
      '#title' => t('Name of contact person'),
      '#type' => 'textfield',
	  '#weight' => -4000
	  ),
	);

2. comment-kazan_hotel.tpl.php:

  <!--Here is where you see the comment_fields_* vars printing into the template-->
    <?php if (!empty($comment_fields_from)) :?>
      <p>From: <?php print $comment_fields_from ?>.</p>
    <?php endif; ?>

    <?php if (!empty($comment_fields_period)) :?>
      <p>Travel period: <?php print $comment_fields_period ?>.</p>
    <?php endif; ?>

3. comment-firm.tpl.php:

<!--Here is where you see the comment_fields_* vars printing into the template-->
    <?php if (!empty($comment_fields_contname)) :?>
      <p>Manager name: <?php print $comment_fields_contname; ?>.</p>
    <?php endif; ?>

In both content types there's nothig instead of values.

I tried to delete 'if' operators - then there was only static text also without values (like "Manager name: .").

Thank You!

aklump’s picture

Status: Closed (works as designed) » Needs review

I discovered that by using the textfield fapi elements the way this was originally setup would not allow this work correctly. I have refactored the code and I'm hoping that solves the issues your facing. Please let me know after downloading version 1.2

kaztur’s picture

aklump, 1.2. version works perfectly!

Great Thanks again! :)

P.S. So, if I spread some not by theme here, I note that Comments Fields is fully compatible with ajax comments module.

aklump’s picture

Status: Needs review » Closed (fixed)

Great! Glad to hear it.