1 node.module node_type_has_content($node_type)

Determine whether a node type has any data.

Parameters

$node_type: Name of bundle to check for content.

Return value

TRUE if the bundle has content associated to it; FALSE otherwise.:

File

core/modules/node/node.module, line 3763
The core module that allows content to be submitted to the site.

Code

function node_type_has_content($node_type) {
  $query = new EntityFieldQuery();
  $query = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $node_type)
    ->range(0, 1)
    ->count()
    // Neutralize the 'entity_field_access' query tag added by
    // field_sql_storage_field_storage_query(). The result cannot depend on the
    // access grants of the current user.
    ->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');

  return (bool) $query
  ->execute() || (bool) $query
  ->age(FIELD_LOAD_REVISION)
    ->execute();
}