Community

display/render in field.tpl - comments /comments_count

DRUPAL 7

Please help to display/render in field.tpl - comments /comments_count of the node.

Hole part of comments and comment form that are in node.tpl

or plus separated comments and comments form.

Why i need this:
I want to move comments into field and change label of field (add comment count in lable). This is for Drupal Commerce.
If comments will be in in field - i can do other effects like to field - for example make it horizontal Tab and so on...

Thank you very much.

Comments

That's a very strange

That's a very strange approach I think. I wouldn't do that if I were you, although you can access node object via $variables['element']['#object'].
Try finding a better solution. Any presentation like Tabs can be easily done via CSS.

love, light n laughter

nothing strange :)

Why it strange? If we get comments in field - we can do with it everything like with field.

Yes, i can do it by css and so on... But comments always will be at the and of tabs list.

I can use Display node, and use module Field group - to hide comments in tab.
But i can't display count of comments in the label of field. And I already need 2 modules. But can use only "field group module" and field.tpl

Please can you write solution using $variables['element']['#object']
Or it too long to write?

Thanks.

Did you install devel.module?

Did you install devel.module? If so try putting, any one of below into your preprocess_field to find out available variables:

  kpr($variables);
  dpm($variables);

See more info http://api.drupal.org/api/function/theme_field/7

If you are working with any of field.tpl directly, you can see there are available variables such as:

* Other variables:
* - $element['#object']: The entity to which the field is attached.
* - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
* - $element['#field_name']: The field name.
* - $element['#field_type']: The field type.
* - $element['#field_language']: The field language.
* - $element['#field_translatable']: Whether the field is translatable or not.
* - $element['#label_display']: Position of label display, inline, above, or
*   hidden.
* - $field_name_css: The css-compatible field name.
* - $field_type_css: The css-compatible field type.
* - $classes_array: Array of html class attribute values. It is flattened
*   into a string within the variable $classes.

Good luck.

love, light n laughter

Thank you for your time!

Thank you for your time!

nobody click here