Add modular page - creating files vs using Admin

I’ve got a modular page template set up in my theme with a couple of modules.

When I create a modular page manually by creating the required files in my user/pages folder, everything works fine. Obviously this way I’m setting up the modular structure myself manually in modular.md.

When I try to create another modular page using Admin instead of dealing with the files, there seems to be a missing feature…

  1. I create the top level page as a modular page.
  2. I use the ‘Add’ button top right to add 2 modules to it, being careful to match the names of the modules I have.
  3. I add content to these modules.
  4. But when I view the page (after clearing the cache), it’s empty.

When I look at the top level page’s frontmatter in advanced mode, all the structure I would expect to see is not there. I’m referring to this:

content:
items: '@self.modular'
order:
    by: default
    dir: asc
    custom:
        - _text2col
        - _text1col

So I had to paste it manually and save, and then the page rendered its content correctly.

This seems odd - it seems that Admin is not updating the modular page’s modular.md when you add modules? Surely it should do that?

As with my earlier post, I’m probably being a noob and missing something obvious!

NB. I’m using 1.7rc20.

No-one?

There has to be a way of creating a new modular page using existing modules, without leaving the Admin console or editing files…

When I look at the top level page’s frontmatter in advanced mode, all the structure I would expect to see is not there. I’m referring to this:

Are you in Advanced mode (like you stated), or Expert mode?

I have never built a modular page in the Admin before. I actually have just crafted my first modular page (it’s a WIP), so I thought I would give this a try. I see that I need to switch it to Expert mode when viewing the top level page.

It auto-generated this front matter for me:

title: test22
content:
    items: '@self.modular'
body_classes: modular

I meant expert mode. It’s quite confusing to have an ‘expert’ button and an ‘advanced’ tab…

I now found how to order the modules within the page (by enabling folder numeric prefix in the options tab of each child module) and when I clear cache, the content is now showing on the page. Yay!

So thank you for prompting me to have another look at the admin editor and its different modes. It meant that I spotted “Page ordering is disabled for this page because Folder Numeric Prefix is not enabled” which I hadn’t seen before.

But this is also confusing - if I can determine the order of the modules by enabling folder numeric prefix on all of them, and then dragdropping in their options tab, I’m not sure what the point is of the “order: custom: etc” in the modular page’s frontmatter, as shown on this page of the documentation:

Guess I should probably take the win and not worry too much about it.

2 Likes

@zigpress,

I’m not sure what the point is of the “order: custom: etc”

A few reasons I can think of:

  • Ordering by ‘Folder numeric prefix’ is only one way to order collections. See ordering options.
  • Collections can be defined dynamically in both PHP and Twig and on any set of pages. You then need more options then ‘Folder numeric prefix’
  • Not everybody is using Admin…
    If not using Admin, would you then rather rename all page folders, or set the order in frontmatter?

All good points - my perspective on Grav is whether I can build sites for clients with it - and they would be using Admin exclusively - no file editing for them (their heads would explode).

@zigpress, That’s a fair reason for using Admin…

Did any of you encounter modules ordering issue on Admin? There’s no way I can make it work purely on Admin side.

No, I haven’t seen that particular behaviour.