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.
@mschoon85 Happy to consider it, which is why it remains open at BookStackApp/BookStack#2065, but there's little demand for extra added complication & maintenance so not something I'd jump to right now.
I did add this to the hacks site here: https://www.bookstackapp.com/hacks/autosort-tagged-books/
If needed, there is an option there to request an update for the latest BookStack version via our hack update service.