function defaultcontent_get_default in Default Content 7
Same name and namespace in other branches
- 7.2 defaultcontent.module \defaultcontent_get_default()
Used to get a machine name or nid
Parameters
$id: An int $nid or a string machine_name
Return value
unknown_type an nid a machine name are an array of machine_name=>nid
14 calls to defaultcontent_get_default()
- content_features_export_options in ./defaultcontent.features.inc 
- Implements hook_features_export_options().
- content_features_revert in ./defaultcontent.features.inc 
- Implements hook_features_revert().
- defaultcontent_alter_path in ./defaultcontent.module 
- defaultcontent_block_view_alter in ./defaultcontent.module 
- Implements hook_block_view_alter().
- defaultcontent_context_block_info_alter in ./defaultcontent.module 
- Implements hook_context_block_info_alter().
File
- ./defaultcontent.module, line 221 
- Module file for the Default content module which allow export and import of default content in a Drupal site.
Code
function defaultcontent_get_default($id = FALSE) {
  if (!$id) {
    return db_select('defaultcontent', 'd')
      ->fields('d', array(
      'name',
      'nid',
    ))
      ->execute();
  }
  $have = is_numeric($id) ? 'nid' : 'name';
  $want = is_numeric($id) ? 'name' : 'nid';
  $values = db_select('defaultcontent', 'd')
    ->condition($have, $id)
    ->fields('d', array(
    $want,
  ))
    ->execute()
    ->fetchCol();
  return !empty($values) ? $values[0] : FALSE;
}