Using "Global" modules

I’m new at this and I’m reading the docs about modular pages. As I understand it this makes it possible to create sub-pages (modules) that then the main page can include.

My question is if it’s possible to have so called “global” modules (sub-pages) that easily can be included by any page regardless if the module is a subpage of the current page or not?

It would be a nice feature to have something like “Save module to global library” where the user could save and organize modules in categories etc and then include these in any pages they want and not just be limited to include sub-pages of the current page. Maybe something for the Admin Pro?

Since this is my first post here I would like to thank the entire Grav team for their amazing work and for taking the time to write comprehensible documentation that even a beginner like me can understand. Looking forward to the Admin Pro plugin and staying with you for many years.

Hi, maybe this is something for @rhukster, but in the meanwhile I’ll answer you first :slight_smile: Roughly speaking the only difference between modular pages and normal pages are that the first are not routable (meaning they don’t have a URL you can use to view the modular page). Thus, modular pages can have taxonomies etc. you can use to built something up like a collection of all your modular pages sorted by a specific category (@rhukster correct me if I’m wrong). They can be located everywhere and can be re-used in other pages as well. There is a plugin for that called Page Inject, which embeds other (modular) pages into your current page. This is maybe what you are looking for.

Thank you for your reply :slight_smile:

I think I understand. But the problem as I see it is that this module (subpage) is still a subpage of another page? And if the main page is deleted then so is all it’s sub-pages? So if let’s say 5 other “main pages” also use this sub-page (module) then there will be nothing there to include or inject?

What I’m looking for is a way to create a module (sub-page) that is completely independent of a main page. Maybe that is possible now but I’m missing this point?

You can put all your modular pages you want to re-use in a separate folder. For example authors. Inside this folder you may want to create one folder for each author and inside them a file with the name author.md and the contents

—yaml
name: AuthorA
routable: false
taxonomy:
author: AuthorA

etc.


You then have multiple ways of including modular pages. Either via Twig (`{{ page.find('/authors/authorA')}}` or `{{ set authors = taxonomy.findTaxonomy({'author': 'AuthorA'}) }}`) or via the above Page Inject plugin (`[plugin:page-inject](/authors/authorA)`). As you can see modular pages are not coupled to (real) pages, but they can if you want.

That could be a solution, thank you!
I will take note of this and dive deeper into the documentation :slight_smile: