You are here

function _tableofcontents_save in Table of Contents 6.3

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

Save the extra data the TOC adds to nodes.

1 call to _tableofcontents_save()
tableofcontents_nodeapi in ./tableofcontents.module
Implementation of hook_nodeapi

File

./tableofcontents.module, line 141
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;
  }
  $sql = "UPDATE {tableofcontents_node_toc} SET toc_automatic = %d WHERE nid = %d";
  db_query($sql, $node->tableofcontents_toc_automatic, $node->nid);
  if (db_affected_rows() == 0) {
    $sql = "INSERT INTO {tableofcontents_node_toc} (nid, toc_automatic) VALUES (%d, %d)";
    db_query($sql, $node->nid, $node->tableofcontents_toc_automatic);
  }
}