Comments (9)
Thank you for the well-researched issue report. I, too, am surprised nobody has mentioned this before. I'll release an update later today.
Grav theme "inheritance" isn't really inheritance at all. You simply replace a file. And because the core instructions tell you to create the theme yaml file from scratch, it simply overwrites the base yaml file. It doesn't extend it. So here's what I'll try to get done today:
- Update the templates to use the correct variable.
- Update the theme's README to explicitly mention how to properly inherit it.
- Submit an issue to Grav suggesting a more intuitive way to inherit yaml files.
- Submit some PRs against Grav's documentation to help future theme developers and customizers.
I'll post here again when the updates are done. Thanks again!
from grav-theme-knowledge-base.
The actual best practice is laid out in the docs. So I'm going to drop that line from base.html.twig
and change all explicit callouts to the theme by name to grav.theme.config
(the longest but most explicit alternate form). It appears to be working in my testing.
It's still not backwards compatible, so I'll have to write up some things, so it won't be done today. They accepted my PR against the inheritance docs, though. I'm making another PR against the theme configuration page to make the best practices explicit.
from grav-theme-knowledge-base.
v2.0.0 released. Thanks!
from grav-theme-knowledge-base.
Thanks for the swift reply! I'm glad my report seems helpful.
Let me add one more thing I just realized now: I had previously not tried how a config in user/config/themes
would behave with inheritance, I was only using the theme folder directly. After a quick test, I can now confirm that in an inheritance setup, having a user/config/themes/knowledge-base.yaml
leads to config.themes['knowledge-base']
not being null
, but instead fetch its values from there. I guess this explains why others didn't have issues - they probably had this file present, as is recommended in your README.
Hence, implementing the suggested changes should not break anything that wasn't already broken. It also suggests that the best way of theme inheritance and configuration is probably as follows:
- Have the theme templates use
theme_config
as described above - Use the
/user/theme/derived-theme/derived-theme.yaml
only for thestreams
section - Copy
knowledge-base.yaml
to/user/config/themes/derived-theme.yaml
and do custom configuration there
from grav-theme-knowledge-base.
But after changing things to theme_config
, the file user/config/themes/knowledge-base.yaml
is no longer seen. Hrm...
from grav-theme-knowledge-base.
I think it's still most correct to go the theme_config
route, but it appears the update would not be backwards compatible. So I'm going to need a little time to decide on the best way to approach this.
I'm going to file an issue with Grav and see what the best practice might be here. Ideally theme inheritance would actually inherit the yaml files instead of replacing them. Obviously you can't do that with twig, but it would work fine with yaml.
from grav-theme-knowledge-base.
Thanks for the update.
I am using the Themer plugin (https://github.com/Sommerregen/grav-plugin-themer) and the default theme used isn't Knowledge Base. I was previously using config.themes['derived-theme'] and it worked perfectly. The update broke the theme though and I had to replace grav.theme.config by config.themes.derived-theme for it to work. So all good now.
I guess my question is: is there any way to make it work automatically without tweaking the templates? i.e. to select which theme config file to look up when this isn't the "activated" theme (as defined by Themer plugin) Because it looks like grav.theme.config looks up the activated theme.
The theme works now for me so I am all good, but I thought I would mention it as this is something to consider. Thank you for this great theme (-:
from grav-theme-knowledge-base.
This is an interesting scenario. I hadn't heard of Themer before now. By "broke the theme" do you mean just that the sidebar disappeared? Or did something more dramatic happen?
You are correct that grav.theme.config
points to the currently activated theme. But it looks like the Themer plugin is indeed activating the theme and updating the whole Grav config object. Did you copy the data from the config file from themes/knowledge-base
into themes/derived-theme
? If so, then I would expect Themer to still correctly resolve grav.theme.config
. Assuming my pull requests get approved, then you wouldn't need to do this and the merging would happen automatically.
I think the grav.theme.config
approach is the best practice for most situations. Someone derives a theme, they want to be able to customize it without changing the templates to manually point to the derived theme's config file.
- I've submitted a PR against the docs to make this (IMO) best practice explicit.
- I've submitted a PR that will make it the default behaviour to merge parent and child config files.
Neither have been reviewed yet, so if Grav doesn't think they're best practices, then I'll have to rethink everything. I'm open to reverting my change to this theme or restructuring it entirely.
from grav-theme-knowledge-base.
I am very sorry it took me so long to reply. I didn't see your answer.
I have copied the data from the config file into the active theme config file and indeed it works (-:
Thanks a lot for this awesome theme (-:
from grav-theme-knowledge-base.
Related Issues (20)
- Multisite. HOT 2
- sort by title HOT 2
- Exclude certain categories from knowledge base HOT 3
- Category missing from list. HOT 4
- Any plan to make this theme responsive? HOT 1
- How to exclude search bar and sidebar from a specific page? HOT 1
- Error 404 on accessing Categories HOT 5
- Navigation menu isnt responsive HOT 7
- relatedpages doesn't work HOT 1
- How should i add two front modules in your theme? HOT 2
- Don't display 'Comments' when the comments plugin is not activated
- Last articles in Sidebar doesn't work when using subdirectories HOT 3
- How to use Category page teplate? HOT 2
- Req: up-to-date skeleton HOT 2
- Req: disable display of page.media.images at end of content HOT 5
- Category links don't work. HOT 1
- Add support for paging the items in a category
- Comments in this theme HOT 2
- Theme inheritence HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grav-theme-knowledge-base.