Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme per page #3082

Open
drzraf opened this issue Nov 25, 2020 · 3 comments
Open

Theme per page #3082

drzraf opened this issue Nov 25, 2020 · 3 comments

Comments

@drzraf
Copy link
Contributor

drzraf commented Nov 25, 2020

I currently use a Grav instance with multiple pages and it happens that I would like a collection of pages (under a give directory) to use a different theme than the active one
I mean, really a different theme (or child theme), not just a new modular. This could be done using custom domains but it's not desirable either. I don't want to change the domain if it's about a dedicated section of the same site.

grav-plugin-themer does this and is quite simple (2 hooks, 3 functions) but:

There are three necessary things within this feature-request:

  1. At page creation: Suggest blueprints from multiple themes rather than only the active one
    1.1. Insert and define a custom field to define the theme in use, eg theme_override
  2. During page edition: Use the blueprint not only based exclusively on the name of the file but also based on theme_override
  3. During frontend rendering: Hook in the template selection logic based on theme_override

The current status is:

  1. grav-plugin-themer already handle this, but at the price of a messy "New Modular / Page" <select>. Having a custom "Add Modular/Page " button in the admin top bar, using add_modals, would be better.
  2. grav-plugin-admin does not support per-page theme. Such modular can not be edited in normal mode because the requested theme's blueprint are not loaded. This could be fixed in the admin plugin, but some core support (or at least an implicit support or a standardization) would be welcome.
  3. grav-plugin-themer already handle this

Overall that's a great feature that could find its way in core without much disruption and would, by standardizing the YAML key defining per-page theme, lead to better support from the admin plugin.

@Sommerregen

@mahagr
Copy link
Member

mahagr commented Dec 1, 2020

The main issue I see with multiple themes is that the page types may be radically different from theme to theme. So it's not enough to set the theme, but you really need to have a setting that picks page type together with theme. Something like template: theme.template...

Another big issue is in how Grav works right now, the theme gets loaded before routing. This would need to change in order to support the feature well enough.

@drzraf
Copy link
Contributor Author

drzraf commented Dec 29, 2020

Do you have a list of existing issues to track this and possibly help on the underlying tasks?

@mahagr
Copy link
Member

mahagr commented Jan 4, 2021

I don't think there's anything related to this -- it's just a known limitation of Grav. The only working way to work around of this, is to have a list of pages with assigned themes before the theme gets loaded.

So basically routing should happen before theme initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants