Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Coming from #2289619: Add a new framework base theme to Drupal core:
Still need to identify how to deal with new versions of a framework that we have implemented as a base theme in core.
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Comments
Comment #2
markhalliwellInitial thoughts:
templates/3.0.0/...
andtemplates/3.3.1/...
.drush.d7.inc
page.3.0.0.tpl.php
andpage.3.3.1.tpl.php
page.3-0-0.tpl.php
andpage.3-3-1.tpl.php
page.300.tpl.php
andpage.331.tpl.php
Comment #3
joelpittetsub-base-themes may be easier to manage because global logic can be kept in the base theme, then the sub can have it's own templates but also
process/preprocess/theme_*/template.php
And if the base shared template needs to change between versions you can override it in the sub-base (probably easier to copy to to old ones and make new versions extend from the base theme.)
Maybe helpful?
Comment #4
markhalliwell@joelpittet, I'm not sure I follow exactly. Can you please elaborate?
This issue isn't about d.o project versioning, but rather external framework versioning.
Comment #5
joelpittetYou have stuff in template.php that make overrides on bootstrap's behalf. (preprocess, process, theme and other hooks). Those may need to change as well between versions, no?
I was trying to say it may be easier to sub base theme each bootstrap version. File name for templates only really works for templates and not theme functions and preprocess, so the " less than ideal" option looks to be more ideal with that consideration.
Comment #6
markhalliwellAh, I see what you mean now. However, no we're not limited to just template files, this can extend to our theme functions and process/preprocess functions as well.
Due to the shear amount of overrides we have to make in this project, we already alter the theme registry so we can organize these functions into separate files for easier management:
Theme hook functions are found in:
*.func.php
Process/Preprocess are found in:
*.vars.php
So the above pattern in #2, for example, could be extended to templates/block/block.vars.php:
block.3-3-1.vars.php
(or something similar)Comment #7
joelpittetAnother reason, with that approach you'd likely need to keep your own registry for thefile_exist()
checks that i would foresee necessary, where you can piggyback off of drupal's registry if they are in a sub-base theme. #problem-for-future-markEdit: scratch that related to template suggestions.
Comment #8
markhalliwellComment #9
markhalliwellThis likely isn't going to happen in 7.x.
In 8.x, this will be much easier since everything is OO and we can extend classes as needed, especially given all the various
@Bootstrap*
plugins that exist now.---
Summarizing what I mentioned in the drupal#bootstrap slack channel:
bootstrap_core
module to the base theme and depend on it.bootstrap_core
would have a site wideversion
setting, where [sub]-themes could override as needed.bootstrap_core
would provide some "version choosing logic", likely a service/handler or something@Bootstrap*
plugin discovery processes.---
Only thing now is to determine naming/path conventions as mentioned in #2.
Comment #10
markhalliwellNot sure this is going to happen for 8.x-3.x either.
Comment #11
rooby CreditAttribution: rooby commentedWhat are the drawbacks to trying to support multiple versions with the same Drupal code?
I haven't looked much yet into the differences between 3 and 4 but the first thing that comes to mind is potentially making things more complex and just as hard to maintain as if you had two separate versions. If that was the case then the effort spent making one module to rule them all would be wasted.
Another related question is, how stable is Drupal's Bootstrap 3 support already? Since bootstrap 3 itself isn't likely to be changing anymore, if we have good coverage of bootstrap 3 in Drupal then there shouldn't really be much work to be done in that version in future right? Or am I off the mark?
I just wonder if this is a worthwhile pursuit.
Maybe I'm just not clear what problem it is trying to solve.
Comment #12
markhalliwellAs we really haven't done this yet, I cannot really answer this properly. I suppose the main "drawback" would be that the project itself may seem to "bloat" in filesize. The typical argument against the "bloat issue" however is almost as large of a misnomer. While there may be additional files, the system itself, while it may have a few more files to scan initially (and then cached), doesn't load any of them until they're actually needed.
As I stated in #2554199: Bootstrap 4, this specific issue isn't a hard blocker for the BS4 release... merely a "nice to have". There are a lot of similarities between the two versions though and if we can get away without having to duplicate code, I'm all for that.
The other reason for a singular code base is partially just due to how d.o, git repositories, versioning and packaging [currently] work. Having separate branches is a lot of work. Having separate projects it's even more work (i.e. overall maintenance costs).
The primary purpose of this issue is to introduce a mechanism that allows us to introduce accumulative changes introduced by newer versions of the external framework.
The best way I can think of describing (as close as possible) for what I'm trying to do here is perhaps how Apple handles its iOS updates.
The underlying architecture of iOS (BS/external framework) relatively remains the same over time.
They release a single update (single project/branch) but it works across multiple devices (multiple BS versions).
Older devices (older BS versions) won't necessarily have all the new features as they're only introduced in newer devices (newer BS versions) that actually support them.
It's quite stable.
BS3 to BS4 is a major change, sure, but I think you may be getting hung up on this specific major version change just a tad due to the aforementioned issue.
Introducing some sort of "versioned" mechanism would also allow us to make changes that were introduced in minor or patch releases of the external framework. These changes can happen when a new feature is introduced, a bug is fixed or a security issue has to fundamentally change the markup.
While Bootstrap certainly attempts to follow semver, that actually hasn't always been the case (they're certainly getting much better about it).
This issue is just a way to help better bridge the external project and existing installs within the Drupal eco-system.
---
Another thing that really hasn't been mentioned yet but has been swirling around in my head is better support for knowing when a sub-theme needs to upgrade their own templates.
Currently, sub-themes that implement their own templates can sometimes get overlooked when the base theme templates have been updated.
Introducing some sort of "versioned" mechanism like this could allow a UI (or CLI) tool to quickly identify which templates in the sub-theme may need updating.
---
Suffice it to say, this issue is far from perfect and I don't have all the answers. That's why this issue exists. However, this is indeed a real issue. One that has become increasingly apparent over the years of maintaining (and upgrading) multiple versions of BS: how to introduce new version changes without breaking BC of existing installs.
This entire issue needs an IS update as well, so tagging as such.
Comment #13
rooby CreditAttribution: rooby commentedThanks for the quick reply. I appreciate the detailed response.
This is definitely something that I think a lot of people overlook when they use a base theme that isn't their own.
I think that the system of checking change records when updating works well (as long as the maintainer of the base theme does change records) but using semver and being able to update patch versions without having to worry about doing anything would be pretty awesome.
Comment #14
markhalliwell#2920309: Add experimental module for Help Topics is using
<meta>
tags in twig templates and a custom discovery mechanism to accomplish similar "metadata" in twig templates, e.g.:In theory, we could do something similar. We'll likely need Semver support to parse the constraints though:
That being said, and perhaps for security reasons, we probably don't want to include this meta info in the template itself. I'm guessing that since help topics are typically only user/admin related, this is less of a concern (edit: it's XSS filtered). Whereas with this project, the templates are public facing.
PHP appears to still be able to parse the metadata (http://ideone.com/uFfQi1) even if they're wrapped in a Twig comment (which PHP has no concept of):
Comment #15
markhalliwellI've gone ahead and opened https://github.com/twigphp/Twig/issues/3082
Comment #16
markhalliwellUsing front matter makes the most sense:
#3064854: Allow Twig templates to use front matter for metadata support
Comment #17
shelaneThis theme will not be supported for Bootstrap 4. See alternative themes for this support.