You are here

function page_title_nodeapi in Page Title 6.2

Same name and namespace in other branches
  1. 5.2 page_title.module \page_title_nodeapi()
  2. 5 page_title.module \page_title_nodeapi()
  3. 6 page_title.module \page_title_nodeapi()

Implementation of hook_nodeapi().

File

./page_title.module, line 382
Enhanced control over the page title (in the head tag).

Code

function page_title_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'update':
      if (isset($node->page_title) && user_access('set page title')) {
        db_query("DELETE FROM {page_title} WHERE type = 'node' AND id = %d", $node->nid);
      }

    // fallthrough to insert intentional!
    case 'insert':
      if (isset($node->page_title) && drupal_strlen(trim($node->page_title)) > 0 && user_access('set page title')) {
        db_query("INSERT INTO {page_title} VALUES ('node', %d, '%s')", $node->nid, $node->page_title);
      }
      break;
    case 'delete':
      db_query("DELETE FROM {page_title} WHERE type = 'node' AND id = %d", $node->nid);
      break;
    case 'load':
      $enabled = (bool) variable_get('page_title_type_' . $node->type . '_showfield', FALSE);
      return array(
        'page_title' => $enabled ? page_title_load_title($node->nid, 'node') : '',
      );
  }
}