Skip to content

helpfulrobot/entidi-silverstripe-autotoc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silverstripe-autotoc

Generate the table of contents dynamically from $Content.

This is basically a SilverStripe 3 module that extends the ContentController class to provide:

  • the new $Autotoc tag, containing the table of contents dynamically created from the content of the current page. The tree is provided as a mixture of ArrayData and ArrayList, ready to be consumed by templates.
  • overriding of the standard $Content tag, augmenting it with anchors (<a> elements with the id attribute but without href) that adds proper destination targets to the links in $Autotoc.

Autotoc format

The $Autotoc is a tree that can be represented with the following pseudo representation:

$Autotoc = ArrayData( $Children <- <CHILDREN> )
<CHILDREN> = ArrayList( <ITEM> )
<ITEM> = ArrayData( $Id, $Title [, $Children <- <CHILDREN> ] )

In a more SilverStripe template way, this can be seen as:

$Autotoc
    $Children[]
        $Id
        $Title
        $Children[]

The Autotoc.ss and AutotocItem.ss shows a way to represent the whole table of content tree in a recursive way. The format used is intentionally compatible with the Bootstrap navlist components, so it can be used and it will be properly handled by the Silverstrap theme.

Support

For bug report or feature requests, go to the dedicated development tracker.

About

Dynamically generates the table of contents

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 97.4%
  • Scheme 2.6%