You are here

function page_title_nodeapi in Page Title 5.2

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

Implementation of hook_nodeapi().

File

./page_title.module, line 222
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 (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':
      return array(
        'page_title' => page_title_load_title($node->nid, 'node'),
      );
  }
}