drupal table of contens works with all text fields on entity

WebMaster's picture

TOC works only with default body field? Drupal issue
By default, It seems the module only works when there is not more than one text field on the entity.

The problem is only for the automatic table of content use case, with more than one text field on the entity.

  • Here is the explanation:
    • The toc filter adds a placeholder that is transformed later at hook_field_attach_view_alter
    • Since there is a restriction based on isset($output['body']) in that hook, the field wouldn't clean up, being messy.
    • The right place to patch is hook_field_attach_view_alter, because is impossible to test in filter, since text filter are not context
    • See Context-aware text filters (provide more meta information to the filter system)

Patch attached.

Drupal documentation wiki style