How to implement SEO-friendly Library URLs in JohnCMS without breaking routing

1
.

Hello everyone,
I’m working on the Library module in JohnCMS and trying to implement SEO-friendly URLs, but I’m running into routing conflicts and some runtime issues.
I would appreciate guidance from anyone who has implemented a similar setup cleanly.
🎯 Target URL structure
I want the Library module to support the following URLs:

/library/
/library/1
/library/1/testing-seo

Instead of:

/library?id=1

❗ Current issues
After implementing custom routing, I’m facing these problems:
1. Route conflict
/library/1 works correctly
/library/1/testing-seo returns 404
/library/ sometimes returns 404 depending on route order
2. Navigation error
Occasionally I get:

NavChain::add(): Argument #1 ($name) must be of type string, null given

This happens when $page_title is not available.
3. Module instability
When I try different routing approaches, either:
index page breaks, or
book detail page breaks
⚙️ Routes I tried
I tested several patterns:

/library/{id}
/library/{id}/{slug?}
/library/{any}

I also attempted manual parsing via REQUEST_URI, but it caused conflicts with the framework router.
🧠 Context
Library module is currently using legacy PHP includes (includes/index/book.php, main.php)
Routing is handled both by JohnCMS router and manual logic inside the module
Slug is currently not stored or validated against database (only decorative)
❓ What I’m looking for
I would like to know the best practice to:
Support SEO-friendly URL like /library/1/slug
Keep /library/1 working without redirect issues
Avoid breaking /library/ index route
Handle optional slug safely without interfering routing
Prevent null values in NavChain / page titles
🙏 Any advice appreciated
If anyone has experience implementing SEO URLs in JohnCMS modules (especially legacy + router hybrid setup), I would appreciate any clean architectural approach or recommended pattern.
Thanks in advance.

.
Кадило крутится, лавэха мутится

This has already been implemented in the current development version of JohnCMS and is planned for release in the next few weeks.

If you need it right away, you can take a look at the current implementation in the repository:

https://github.com/johncms/johncms/blob/9.x/modules/library/config/routes.php

Please note that the Library module has been significantly refactored since the legacy version, so the implementation is quite different from the code you're currently working with. It should be viewed more as a reference than a drop-in solution.

.

Thank you for the information. I understand. I will wait for the official update from JohnCMS. I appreciate your help and guidance.

Всего: 3