You are here

function page_title_nodeapi in Page Title 5

Same name and namespace in other branches
  1. 5.2 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 107
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':
      db_query("DELETE FROM {page_title} WHERE nid = %d", $node->nid);

    // fallthrough to insert intentional!
    case 'insert':
      if (strlen(trim($node->page_title)) > 0) {
        db_query("INSERT INTO {page_title} VALUES (%d, '%s')", $node->nid, $node->page_title);
      }
      break;
    case 'delete':
      db_query('DELETE FROM {page_title} WHERE nid = %d', $node->nid);
      break;
    case 'load':
      $object = new stdClass();
      $object->page_title = page_title_node_get_title($node->nid);
      return array(
        'page_title' => $object->page_title,
      );
    case 'view':
      if ($page) {
        page_title_set_title($node->page_title);
      }
      break;
  }
}