Auto Scroll Spy
Auto Scroll Spy is a simple package for Joomla 4 which automatically generates a table of contents for an article based on its headings. Optionally, you can turn scroll spy on too, which makes it easy for users to see where they are on the page. It automatically highlights the current section they're under. In hindsight, I should have named it something with a better acronym.
This package has a module and a system plugin. You enable both of them. When a user visits a page with more than a certain number of headings (you specify), the extension will generate and show them a clickable table of contents based on the article headings.
You can see a demo of this in action by just looking at the sidebar of this website for any article with over 4 headings, such as this page.
Here are some screenshots of the plugin in action...
How to Use
Install the package. Then, enable the plugin through Joomla's plugin manager (under System -> Plugins -> "Auto ScrollSpy (Table of Contents)")
You should also take a look at the plugin's settings. This is where all the important stuff is.
Set your level 1 and level 2 elements, these are the elements that the plugin will automatically make a table of contents based off of. For example, if you select "Heading 3" and "Heading 4" it will use all heading 3s and heading 4s for headings in your article. Of course, this means you'd also have to ensure your articles are written using the elements you selected.
If you're not familiar with HTML or web development, you want to ensure you're selecting the corresponding "headings" when you create headings in your articles. The default plugin uses heading 2 and 3. So if I want my table of contents to work, I need to ensure the articles have level 2 headings in them.
To format something as a Heading level 2, from the article editor, you can just highlight the text you want to turn into a heading and go to the formatting menu. Then select "Heading 2," "Heading 3, or the respective option you've set in the plugin settings.
Finally, you'll want to enable and publish the included module somewhere on your site. It should be visible on all pages where you're planning on using a table of contents. It should be okay to publish this module on all pages of your site - as the module will not display when the plugin detects the user isn't in an article that meets the requirements to display a table of contents.
For more information on what each option does in the plugin settings, and before asking any questions, please be sure you click the "Toggle Inline Help" button from the plugin settings page! This explains what each field does in detail.
The plugin can also be set to work as a floating panel which expands when the user clicks an icon. I've included this to make the plugin work with as many templates as possible. However, note that in general the module will probably provide a better experience.
If you've tried using all the different settings and still cannot get it working, please reach out to me in the forums. I cannot guarantee support for every question. If you want priority support please leave a tip or purchase a subscription. If you'd like me to customize the plugin to match the style of an existing website, please contact me for details (approx. $30 for basic customizations).