Hi I whant too create 2 code field
one that show how many time the node have bean viewd
and one that show how many comments there is in the node.
but I can't find any were how to do this hope someone know's how to do this.

Comments

swentel’s picture

Title: Need help creating Code field. » Support for comments and statistics

Well if you go to admin/ds/nd/fields, you can create a new field via the interface. Following code will output the number of comments:

print $object->comment_count;

You can also create your own module and implement hook_ds_fields - Take a look in nd.module how we created the read_more button and replace the code from that with the PHP code above.

The code for statistics should look a bit like this:

$statistics = statistics_get($object->nid);
if ($statistics) {
  print format_plural($statistics['totalcount'], '1 read', '@count reads');
}

I'm changing the title a bit, because we're going to add those two fields as default in the node displays module this weekend too.

swentel’s picture

Status: Active » Fixed

Actually, I've added these snippets on a separate page on the documentation pages, http://drupal.org/node/700056
For now, we aren't going to add these fields by default.

wibbla’s picture

Thanks for the help m8.

Status: Fixed » Closed (fixed)

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