We’re just looking into Grav, and from what we’ve seen we love it. However, to make a business case for it we’ve got a couple of questions that need answering.
The first is, is there a way to reuse modules? For example, have a list page that is used as a module on every modular page (it would be in the sidebar) - or is there/should I be making a plugin? And can pages (item and list) be used as part of a modular page as well as having their own route?
To be a little less abstract, we have a child type (type1) that in the sidebar will need to have a custom defined list of a different child type (type2) - the list that shows on every page, a list of related (we’ll probably use categories or tags) of type2, and a similar list of type3.
And that’s barely less abstract isn’t it. What would be a grav way of doing that?
Sure this can be done. The problem lies in the fact that it can be done in many ways.
Grav really doesn’t have the concept of a modular in the Joomla/WordPress way of things. There are no positions that you put things in. Everything is based on a theme, and in that theme you can define how and where things are displayed.
The simplest way is to have a template that a common set of pages share (for example
item.html.twig in antimatter theme. These both include a
partials/sidebar.html.twig and in this sidebar there is a variety to stuff.
If that ‘stuff’ in the sidebar requires some advanced logic (e.g. taxonomy list, page archives, whatever), a plugin is usually used to gather the data and store some object in the Twig environment. This object is then simply accessed via the Twig template.
This is the approach taken by most of our plugins that are intended for output, and then they act very similar to Modules in Joomla or Widgets in WordPress, other than the fact that you need to manually ‘include’ the twig template in your theme.
The oth er interesting fact, is that we are bringing Gantry5 to Grav. This provides a full set of powerful layout functionality that will enable you do develop a site in a very familiar way if you have worked with Joomla/WordPress in the past. This work will get underway next week.
Thanks, that’s very helpful. I was thinking of modular pages as any pages that have a more complex use of other pages, but it does make more sense to be using plugins.