Elxis CMS Forum
Support => General => Topic started by: armpouniotis on March 02, 2020, 14:13:45
-
Hi there !
is there any plugin or module that I can use, in order to make table of contents in an article ?
I want something similar to wikipedia pages, which have table of contents at the top of page !
Thank you in advance !
Christos
-
Try the Category map (https://www.elxis.net/edc/content/19.html) module, which may can cover your needs. If you want to show more columns, in order the final result to look as table, then you can use copies of the module, displaying them one beside to the other. And in order to show the modules inside articles you can use the Include module plugin (https://www.elxis.net/edc/miscellaneous/117.html).
-
Category map doesn't do what I really want. It is not even close to wikipedia style.
Christos
-
Your request was not so clear to me, so I supposed that you need something like category map.
-
There is nothing ready for this. You can do it manually on each article (not very useful) or use a js library to create TOC automatically based on your content classes:
Like this: https://advanced-js.github.io/syllabus/
or this: https://tscanlin.github.io/tocbot/
or this: https://www.jqueryscript.net/demo/jQuery-Plugin-For-Simple-Table-of-Contents-toc/
For your ease, you can create a simple content plugin to include and initialise the library in the desired articles.
-
Thank you for your solution, but
sorry but I can't do this in 100 pages !
Thank you anyway !
Christos
-
A table of contents needs nothing more than simple html with internal links.
Example:
<a href="#chapter1">Chapter 1</a><br />
<a href="#chapter2">Chapter 2</a><br />
<a href="#chapter3">Chapter 3</a><br />
<h3 id="chapter1">Chapter 1</h3>
<p>blah blah blah</p>
<h3 id="chapter2">Chapter 2</h3>
<p>blah blah blah</p>
<h3 id="chapter3">Chapter 3</h3>
<p>blah blah blah</p>
That's all!
-
Yes, I am aware of this coding very well, but I was just wondering if there is any other automatic way using any of the available modules, since I am about to have table of contents in many many articles !
Thank you anyways !
Christos
-
Hmmm.... (thinking...)
I can do something for you. I can create a plugin that will generate automatically a TOC on all of your articles but in order to work each article has to contain h2 or h3 or similar tags. The plugin will treat these headers as entries for the TOC. If there are no such headers in your articles such a plugin cannot work.
Example:
<h2>Section A</h2>
<h3>Section A1</h3>
<p>blah blah</p>
<h3>Section A2</h3>
<p>blah blah</p>
<h2>Section B</h2>
...
If your articles are formatted like that, or with just h3 tags, or with h2, or with h4, a special plugin could do your job. In order not to integrate the plugin on every page the plugin could work without integration into the editor by activating an option in its parameter. So you wont even have to edit your articles... I am also thinking of deactivating automatically the TOC in case only 1 H tag is found. Or even specific the categories you want the plugin to generate TOCs.
-
Well, that looks a great idea of yours ! I think it is going to be useful in future tasks ! I what you have described so far about the plugin looks easy to use !
I am waiting for the final result !
Thank you in advance
Christos