Multiple markdown instances

How can I create a page with multiple markdown instances? And how can I label those markdown instances with a title in the admin view?

Use case: Let’s say there’s a page with two columns. Or better yet, a 4-quadrant grid. Or some other similar situation where content is not just a single dump of text.

In such cases, multiple markdown editor instances are needed… and it would be helpful to label them, so admin users know which instance controls the text for which quadrant.

Grav, by default, seems to expect all pages will only ever contain a single dump of content.

How can I generate the approximate equivalent of this pseudo-code concept:

<div id="one" class="content">{{ markdown_editor: 'Upper Left' }}</div>
<div id="two" class="special"><some complex html with javascript controlling hidden content panels></div>
<div id="three" class="carousel"><some gallery widget that swaps images or videos through some interaction></div>
<div id="four" class="content">{{ markdown_editor: 'Lower Right' }}</div>

As you can see, such a page would have more complexity that just the simplistic ‘header → plain old content → footer’ model. The admin needs the ability to edit two of the quadrants which contain relatively simple content. But the other two quadrants need some other controls entirely.

I can’t be the first to encounter this need, so any help pointing me in the right direction would be appreciated.


It appears what I’m looking for is to create a modular page, although the documentation isn’t quite straightforward.

A modular page, in my example above, would be built from four submodules (one for each of the divs).

In the user/themes/my-theme folder, the actual page (example mymodularpage.html.twig) is defined with instructions to grab four submodules from a subfolder (example: user/themes/my-thememodularpage). That subfolder contains the html for each submodule (submodule-abc.html.twig, submodule-xyz.html.twig). Any submodule which needs a text editor will reference {{content | raw}} in the twig.

Then, in the admin view, I create a new page using the Modular Page template where the markdown for that page is left blank (although I’d prefer to remove that editor altogether to avoid confusion – anyway to do that? why is it automatically there in the first place when no code asked for it?). At this point, the page has no content and no submodules defined. It’s basically a placeholder stub.

Next, you must look for the Expert button in order to define a text list of what submodules will eventually be used to construct the page. (This is the equivalent of modifying the list in the file.) However, this configuration list by itself doesn’t actually activate any submodules. It’s unclear why this is a necessary step, but it’s apparently necessary. And now that you’ve defined the list of what submodules you intend to be associated with this parent page, you should now save the parent page with no content.

Then, afterwards, the admin must next click the “Add +” button in the top right in order to specify which is the first submodule that should be bundled on this page. (Yes, even though you specified in the configuration what the list of submodules was, you must still Add them one at a time manually. Why? No idea. It just is.) Save again.

Note as soon as you save, your admin view is now hierarchically in the submodule, so you have navigate back to the parent page (or else you’ll get a submodule of a submodule) to add the next module. Save again, navigate back to the parent, repeat as necessary.

What’s awkward is that when you’re on the edit view for the parent page, there is no list of what submodules are associated. You can only see that from the sitemap view.

On the admin view of the sitemap, there is a column for pages and a column for submodules, but there is no clear indication of which page you are currently seeing submodules for. It seems as if the assumption is that only one page will ever contain submodules, therefore there’s no need to visually indicate which page the current list of displayed submodules belongs to. It’s pretty confusing and a simple folder tree view would solve it.

If I need several such modular templates very different from one another, I must create additional twigs (modularpage1.html.twig and modularpage2.html.twig, etc). For each of those, there must be a subfolder (_modularpage1 and _modularpage2) which respectively contain the submodule twig files.

The more such pages you have, the more complex the admin interface gets. It’d be so much easier to see submodules visually as children of the parent page.

If anyone has additional clarification or tips, your input would be helpful.