You are here

function page_title_node_update in Page Title 8.2

Same name and namespace in other branches
  1. 7.2 page_title.module \page_title_node_update()
  2. 7 page_title.module \page_title_node_update()

Implement hook_node_update().

File

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

Code

function page_title_node_update($node) {
  if (user_access('set page title') && isset($node->page_title)) {

    // If there is content to the Page Title, 'merge' it (ie, either UPDATE or INSERT)
    if (drupal_strlen(trim($node->page_title)) > 0) {
      db_merge('page_title')
        ->key(array(
        'type' => 'node',
        'id' => $node->nid,
      ))
        ->fields(array(
        'page_title' => $node->page_title,
      ))
        ->execute();
    }
    else {
      db_delete('page_title')
        ->condition('type', 'node')
        ->condition('id', $node->nid)
        ->execute();
    }
  }
}