Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Add modular page - creating files vs using Admin

Solved by PLEASE DELETE THIS ACCOUNT View solution

Started by PLEASE DELETE THIS ACCOUNT 5 years ago · 8 replies · 1276 views
5 years ago

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:

YAML
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.

5 years ago

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...

5 years ago

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:

YAML
title: test22
content:
    items: '@self.modular'
body_classes: modular
5 years ago Solution

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:

https://learn.getgrav.org/17/content/modular

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

👍 2
5 years ago

@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?
5 years ago

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).

5 years ago

@zigpress, That's a fair reason for using Admin...

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 57 14 hours ago
Support · by Anna, 3 days ago
2 65 17 hours ago
Support · by Justin Young, 18 hours ago
1 33 18 hours ago
Support · by Duc , 1 week ago
2 68 5 days ago
Support · by Colin Hume, 1 week ago
2 60 6 days ago