diff --git a/config/config.ini.example b/config/config.ini.example
index cb345f9..04b2127 100644
--- a/config/config.ini.example
+++ b/config/config.ini.example
@@ -135,6 +135,12 @@ cache.timestamp = "false"
; The site.url depends on where you are visiting from. Same installation
multi.site = "false"
+; TOC label
+toc.label = "Table of Contents"
+
+; TOC inital state
+toc.state = "close"
+
; Set the theme here
views.root = "themes/twentysixteen"
diff --git a/content/data/configList.json b/content/data/configList.json
index b3dc5c9..d06cd6e 100644
--- a/content/data/configList.json
+++ b/content/data/configList.json
@@ -1 +1 @@
-["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","tagcloud.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","multi.site","views.root","views.layout"]
\ No newline at end of file
+["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","tagcloud.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","multi.site","toc.label","toc.state","views.root","views.layout"]
\ No newline at end of file
diff --git a/system/admin/views/config-widget.html.php b/system/admin/views/config-widget.html.php
index eea38ab..ec5c5d6 100644
--- a/system/admin/views/config-widget.html.php
+++ b/system/admin/views/config-widget.html.php
@@ -58,6 +58,34 @@
+
TOC (Table of Contents)
+
+
+
+
diff --git a/system/includes/functions.php b/system/includes/functions.php
index 50cb0b1..24a2f57 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -519,7 +519,15 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
$toc = explode('', $post->body);
- if (isset($toc['1'])) {
+ if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -533,7 +541,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
});
EOF;
- $post->body = $toc['0'] . $load . '' . $toc['1'];
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
}
// Convert image tags to figures
@@ -601,7 +609,15 @@ function get_pages($pages, $page = 1, $perpage = 0)
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
$toc = explode('', $post->body);
- if (isset($toc['1'])) {
+ if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -615,7 +631,7 @@ function get_pages($pages, $page = 1, $perpage = 0)
});
EOF;
- $post->body = $toc['0'] . $load . '' . $toc['1'];
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
}
if (config('views.counter') == 'true') {
@@ -690,6 +706,14 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
$toc = explode('', $post->body);
if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -703,7 +727,7 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
});
EOF;
- $post->body = $toc['0'] . $load . '' . $toc['1'];
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
}
if (config('views.counter') == 'true') {
@@ -984,7 +1008,15 @@ function read_category_info($category)
$desc->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
$toc = explode('', $desc->body);
- if (isset($toc['1'])) {
+ if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -998,7 +1030,7 @@ function read_category_info($category)
});
EOF;
- $desc->body = $toc['0'] . $load . '' . $toc['1'];
+ $desc->body = $toc['0'] . $load . '' . $toc['1'];
}
$desc->description = get_content_tag("d", $content, get_description($desc->body));
@@ -1230,6 +1262,14 @@ function get_author($name)
$toc = explode('', $author->about);
if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -1243,7 +1283,7 @@ function get_author($name)
});
EOF;
- $author->about = $toc['0'] . $load . '' . $toc['1'];
+ $author->about = $toc['0'] . $load . '' . $toc['1'];
}
$author->body = $author->about;
@@ -1296,7 +1336,15 @@ function get_frontpage()
// Get the contents and convert it to HTML
$front->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
$toc = explode('', $front->body);
- if (isset($toc['1'])) {
+ if (isset($toc['1'])) {
+ $state = config('toc.state');
+ if ($state !== 'open') {
+ $state = 'close';
+ }
+ $label = config('toc.label');
+ if (empty($label)) {
+ $label = 'Table of Contents';
+ }
$load = <<
document.addEventListener("DOMContentLoaded", function() {
@@ -1310,7 +1358,7 @@ function get_frontpage()
});
EOF;
- $front->body = $toc['0'] . $load . '' . $toc['1'];
+ $front->body = $toc['0'] . $load . '' . $toc['1'];
}
} else {
$front->title = 'Welcome';