Hi, this plugin seems to be really nice.
But has anyone found a way to include it automatically on every page, i.e. in the template?
By the way, here is a backup of Shawn's documentation in the wayback machine:
https://web.archive.org/web/201906200432...oc-plugin/
Perhaps there is a way to add this to the forum, if it is still correct.
Edit:
Ok, here is what I did to insert the ToC automatically.
I messed around in the plugin's source and prependend the existing filter with another one. The new filter prepends the content with a home div for the ToC tag.
Then comes the existing filter and builds the ToC there.
So here is the original version:
and I replaced this with:
This way, the ToC will always per default reside on the right top corner of the content area.
And now,
But has anyone found a way to include it automatically on every page, i.e. in the template?
By the way, here is a backup of Shawn's documentation in the wayback machine:
https://web.archive.org/web/201906200432...oc-plugin/
Perhaps there is a way to add this to the forum, if it is still correct.
Edit:
Ok, here is what I did to insert the ToC automatically.
I messed around in the plugin's source and prependend the existing filter with another one. The new filter prepends the content with a home div for the ToC tag.
Then comes the existing filter and builds the ToC there.
So here is the original version:
PHP Code:
# activate filter
add_filter('content','add_toc');
and I replaced this with:
PHP Code:
# prepend trigger div
add_filter('content', 'prepend_toc_div');
function prepend_toc_div($contents) {
$toc_div = '<div class="sa_toc_div" id="sa_toc_div" style="float:right;">(% sa_toc depth=2 %)</div>';
return $toc_div.$contents;
}
# activate filter
add_filter('content','add_toc');
This way, the ToC will always per default reside on the right top corner of the content area.
And now,
- you can style the ToC and it's contents with a .sa_toc_div css class,
- or grab it via javascript as #sa_toc_div, and put it somewhere else in den DOM ...