Commit 7a16a05b authored by jsacksick's avatar jsacksick Committed by fago

Issue #1414688 by jsacksick: Add the comments property in...

Issue #1414688 by jsacksick: Add the comments property in entity_metadata_node_entity_property_info().
parent cef1ea5f
...@@ -92,6 +92,12 @@ function entity_metadata_comment_get_node_properties($node, array $options, $nam ...@@ -92,6 +92,12 @@ function entity_metadata_comment_get_node_properties($node, array $options, $nam
case 'comment_count_new': case 'comment_count_new':
return comment_num_new($node->nid); return comment_num_new($node->nid);
case 'comments':
$select = db_select('comment', 'c')
->fields('c', array('cid'))
->condition('c.nid', $node->nid);
return array_keys($select->execute()->fetchAllKeyed(0, 0));
} }
} }
......
...@@ -137,6 +137,13 @@ function entity_metadata_comment_entity_property_info_alter(&$info) { ...@@ -137,6 +137,13 @@ function entity_metadata_comment_entity_property_info_alter(&$info) {
'setter permission' => 'administer comments', 'setter permission' => 'administer comments',
'type' => 'integer', 'type' => 'integer',
); );
$properties['comments'] = array(
'label' => t("Comments"),
'type' => 'list<comment>',
'description' => t("The node comments."),
'getter callback' => 'entity_metadata_comment_get_node_properties',
'computed' => TRUE,
);
$properties['comment_count'] = array( $properties['comment_count'] = array(
'label' => t("Comment count"), 'label' => t("Comment count"),
'description' => t("The number of comments posted on a node."), 'description' => t("The number of comments posted on a node."),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment