You are here

function references_dialog_node_reference_add_link in References dialog 7

Add link callback for node references.

2 string references to 'references_dialog_node_reference_add_link'
hook_references_dialog_widgets in ./references_dialog.api.php
Define a widget to which you want to attach add, search or edit links.
references_dialog_references_dialog_widgets in ./references_dialog.dialog_widgets.inc
Implements hook_references_dialog_widgets().

File

./references_dialog.dialog_widgets.inc, line 133
Implements dialogs for node reference and user reference fields.

Code

function references_dialog_node_reference_add_link($element, $widget_settings, $field, $instance) {
  $add_links = array();
  foreach ($field['settings']['referenceable_types'] as $type => $active) {
    if ($active !== 0) {
      $node_type = node_type_load($type);
      if (node_access('create', $node_type->type)) {
        $add_links[] = array(
          'title' => t('Create @type', array(
            '@type' => $node_type->name,
          )),
          'href' => 'node/add/' . strtr($type, array(
            '_' => '-',
          )),
        );
      }
    }
  }
  return $add_links;
}