You are here

function edit_link_node_view in Util 7

Implements hook_link().

File

contribs/edit_link/edit_link.module, line 10
Add an 'edit' link to nodes.

Code

function edit_link_node_view($node, $view_mode) {
  static $ntypes;
  if ($view_mode == 'teaser' && node_access('update', $node)) {
    $objtype = 'post';
    if (variable_get('edit_link_type', 0)) {
      if (!isset($ntypes)) {
        $ntypes = node_type_get_names();
      }
      $objtype = $ntypes[$node->type];
    }
    return $node->content['links']['util-edit-link'] = array(
      '#links' => array(
        array(
          'title' => t('Edit this @type', array(
            '@type' => $objtype,
          )),
          'href' => "node/{$node->nid}/edit",
          'attributes' => array(
            'title' => t('Edit this @type', array(
              '@type' => $node->type,
            )),
          ),
        ),
      ),
    );
  }
}