You are here

function example_link in Coder 7.2

Same name and namespace in other branches
  1. 7 coder_upgrade/tests/old/samples/example.module \example_link()

The signature is hook_link($type, $object, $teaser = FALSE). We need to determine the variable name used in the second parameter and use this in the code to be inserted. If it is $object, then change to $node when moving to hook_node_view.

File

coder_upgrade/tests/old/samples/example.module, line 2246

Code

function example_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();
  if ($type == 'node' && $node->type == 'blog') {
    if (arg(0) != 'blog' || arg(1) != $node->uid) {
      $links['blog_usernames_blog'] = array(
        'title' => t("!username's blog", array(
          '!username' => $node->name,
        )),
        'href' => "blog/{$node->uid}",
        'attributes' => array(
          'title' => t("Read !username's latest blog entries.", array(
            '!username' => $node->name,
          )),
        ),
      );
    }
  }
  if ($type == 'comment' && $node->type == 'blog') {
    if (arg(0) != 'blog' || arg(1) != $node->uid) {
      $links['blog_usernames_blog'] = array(
        'title' => t("!username's blog", array(
          '!username' => $node->name,
        )),
        'href' => "blog/{$node->uid}",
        'attributes' => array(
          'title' => t("Read !username's latest blog entries.", array(
            '!username' => $node->name,
          )),
        ),
      );
    }
  }
  return $links;

  /* Add this to the outer if block before moving it all to the hook_node_view code.
        $node->content['links']['blog'] = array(
          '#theme' => 'links',
          '#links' => $links,
        );
    */
}