This is a hack to BookStack, using the theme system, to enable auto-sorting of book chapters and pages upon page or chapter create/update.
It sorts by name, ascending, with chapters first.
By default it will run for any book with an Autosort
tag assigned.
This uses the logical theme system.
- Within the BookStack install folder, you should have a
themes
folder. - Create a
themes/custom/functions.php
file with the contents of thefunctions.php
file example below. - Customize the tag name, if desired, by teaking the string at around line 45. Set this to empty to run for all books.
- Add
APP_THEME=custom
to your .env file.
This can slow down page & chapter create & update system events. These customizations are not officially supported any may break upon, or conflict with, future updates. Quickly tested on BookStack v22.11.1.
Hi @ssddanbrown ,
I understand that this is not officially supported, but BookStack is continuously growing within our organization, accumulating more chapters and pages. We use BookStack as a Knowledge Base, and manually sorting entries after creating a page or chapter is highly inconvenient. Strangely, books auto-sort already. I attempted the solution mentioned above, but it resulted in a "Something went wrong" error. We are currently using release 24.05.1. Would you consider integrating this feature into BookStack by default?
Kind regards,
Michel