winter: this.theme.id breaks after adding customization to theme.yaml
Winter CMS Build
1.2
PHP Version
8.1
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
When adding fields to theme.yaml , theme.id breaks and returns an integer instead of string (sanitized dirName)
Tested on brand-new setup with demo theme.
{{ this.theme.id }}
{{ this.theme.dirName }}
1
demo
Steps to replicate
- Setup demo theme
- Output
{{ this.theme.id }}anywhere on the page - See expected string matching folder name
- Modify theme.yaml adding:
form:
fields:
site_name:
label: Site name
comment: The website name as it should appear on the frontend
default: My Amazing Site!
- refresh the page and see an integer instead of the theme folder name
Workaround
I’ve switched to theme.dirName, since it’s public as well.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 16 (10 by maintainers)
yes, I have tested this.
@alekseyp it doesn’t appear to be random - it’s the ID of the record in the
cms_theme_datatable, which is created when you have customisable data in your theme. It’s effectively caused by a race condition due to the rules of Twig’s access logic that we’ve implemented in the CMS module - thegetIdmethod which normally provides the directory is not run because theThemeDatamodel record has anidproperty, which is a higher priority in that logic.