You are here

function _tableofcontents_apply_toc in Table of Contents 7.2

1 call to _tableofcontents_apply_toc()
tableofcontents_field_attach_view_alter in ./tableofcontents.module
Implementation of hook_field_attach_view_alter(&$output, $context)

File

./tableofcontents.module, line 139
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_apply_toc($text, $entity_type, $bundle) {

  // There's no [toc] in this field, skip it.
  if (strpos($text, '[toc') === FALSE) {
    return FALSE;
  }

  // We're not touching this type of entity/bundle
  if (!variable_get("tableofcontents_{$entity_type}_{$bundle}", TRUE)) {
    return FALSE;
  }

  // Okay let's take a look at the settings
  $toc = _tableofcontents_toc_extract($text);
  if ($toc['on_off']['hide']) {

    // we're not displaying anything for this field anyway at present
    return FALSE;
  }

  // Set the [toc] globally
  tableofcontents_toc($toc);
  return TRUE;
}