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.

General

Modular page best use case

Started by Matteo Rossi 8 years ago · 4 replies · 678 views
8 years ago

Hi there,

I'm trying to figure out the best use-case for modular pages.

From what I get from the documentation, modular pages are meant to build complex UI splitting the page in several modules (each module have it's own template under modular directory and, eventually, a specific blueprint).

Now, for my purpose I've to create several pages, let's say homepage, contacts, about us and so on. Each page has unique UI and does not share any reusable component (let's say module).

In this case, is recommended to create 1 unique twig template for each page or go with several modular blocks (each prefixed with page name e.g. homepage has homepage_heading.html.twig and so on..) ?

8 years ago

Hi
I think the primary benefits of modular pages being easy reuse layouts and a bit easier to maintain content in the admin panel. It sounds like modular pages would be unnecessary in your case. If you ever need to add in some universal content like a call to action button or headers/footers you can do that easily enough using a partial.

8 years ago

I do agree with you.

I think that modules in modular pages are designed to be self-contained reusable chunk of code with specific blueprint that let users handle theirs data from admin panel.

Looking at my scenario I found that partials pattern (I'm used to Ruby on Rails) more suitable since each page does not share any component (like Features in the Antimatter starter) except for header and footer.

By attaching a blueprint to my homepage.html.twig I can handle data from admin panel, am I right?

8 years ago

Yes that is correct. Also, the blueprint is not exclusive so you can put say 90% of the page content hard coded into the twig file and only have a few modifiable fields in the blueprint or vice versa. You might find uploading new twig files far easier than messing around with admin panel fields.

👍 1
8 years ago

Yeah that's exactly what I'm doing since my client need to edit few fields, the others are hardcoded in the twig template 🙂 Thank you for your support!

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 95 15 hours ago
General · by pamtbaau, 20 hours ago
1 61 19 hours ago
General · by Andy Miller, 1 day ago
0 47 1 day ago
General · by Marcel, 12 months ago
6 356 5 days ago
General · by Duc , 6 days ago
3 44 6 days ago