You are here

function _tableofcontents_save in Table of Contents 7

Same name and namespace in other branches
  1. 6.3 tableofcontents.module \_tableofcontents_save()

Save the extra data the TOC adds to nodes.

2 calls to _tableofcontents_save()
tableofcontents_node_insert in ./tableofcontents.module
Implementation of hook_node_insert
tableofcontents_node_update in ./tableofcontents.module
Implementation of hook_node_update

File

./tableofcontents.module, line 133
This is a filter module to generate a collapsible jquery enabled mediawiki style table of contents based on <h[1-6]> tags. Transforms header tags into named anchors.

Code

function _tableofcontents_save($node) {

  // new nodes will not have our parameter set, make sure we have a default
  if (!isset($node->tableofcontents_toc_automatic)) {
    $node->tableofcontents_toc_automatic = 0;
  }
  $num_updated = db_update('tableofcontents_node_toc')
    ->fields(array(
    'toc_automatic' => $node->tableofcontents_toc_automatic,
  ))
    ->condition('nid', $node->nid)
    ->execute();
  if ($num_updated == 0) {
    db_insert('tableofcontents_node_toc')
      ->fields(array(
      'nid' => $node->nid,
      'toc_automatic' => $node->tableofcontents_toc_automatic,
    ))
      ->execute();
  }
}