Hi,

My question is simple: is it a way to show the toc on every nodes, even if they don't have any title?(the toc will be empty but it's not a problem)

I tried to fix "Number of headers before an automatic table of content is added:" to 0 but it don't work.

Thanks!

Comments

AlexisWilke’s picture

sjeandroz,

tableofcontents/tableofcontents.pages.inc checkc whether $max == 0. You have to remove that test. Also, if using automatic toc, then the following test probably needs to be removed too: if ($max < $min_limit).

  // Any headers? if not do nothing...
  $max = count($_tableofcontents_toc->headers);
// -- DELETE FROM HERE --
  if ($max == 0) {
    // not even 1 header!!!
    if ($_tableofcontents_block_toc) {
      return '';
    }
    return preg_replace(TABLEOFCONTENTS_REMOVE_PATTERN, '', $org_text);
  }
// -- TO HERE --

  // If automatic verify the limit, if not reached, bail out
// -- DELETE FROM HERE --
  if ($_tableofcontents_toc->automatic) {
    $min_limit = variable_get('tableofcontents_min_limit_' . $format, 5);
    if ($max < $min_limit) {
      // Limit not reached!
      if ($_tableofcontents_block_toc) {
        return '';
      }
      return preg_replace(TABLEOFCONTENTS_REMOVE_PATTERN, '', $org_text);
    }
  }
// -- TO HERE --

Thank you.
Alexis Wilke

sjeandroz’s picture

Thanks a lot! it works!

thanks thanks thanks!

sjeandroz’s picture

hello!,

This solution works except now I have an empty toc on each comments..

AlexisWilke’s picture

You want to create a different filter for the comments than for the nodes. And the filter for the comments does not include the table of contents filter.

Thank you.
Alexis