I am looking at converting a module I wrote and integrating it straight into my theme so as to reduce dependencies.
At first when I wrote the module as I was under the impression that a theme was not able to use hooks such as hook_page_attachments and hook_libraries_info_alter etc. It doesn't seem that bootstrap has this problem as I am fully able to leverage those hooks.
So this got to me wondering what are the chief limitations of a Bootstrap theme as compared to a module?
I know that themes can't currently depend on modules which is being tracked here:
#474684: Allow themes to declare dependencies on modules
Just was curious as wanted to start my module port and wasn't sure if I would hit any roadblocks.
I am mostly porting some custom blocks, controllers, ckeditor plugin and a few services. The one concern I do have is I have a relatively complicated settings form coupled with a pretty big schema.yml file.
Comments
Comment #2
markhalliwellActually there's quite a bit that themes cannot do, especially now in 8.x:
As far as a "list" of what alter hooks themes are allowed to participate in... I really don't know of any. This base theme implements the majority/common alters hooks found in themes and you can see what it implements in bootstrap.theme. The only other suggestion I would have towards this subject is to see what code implements the module alter and see if there's a theme alter along with it.
{system}
will automatically add the namespaces to the autoloader. That being said there is a small caveat, generally when dealing with cross-request/ajax theme class based callbacks, that prevent the namespaces from being registered in themes when logic is being processed too early in a low level bootstrapped request. This is why I added the Bootstrap::autoloadFixInclude helper method so autoload-fix.php can be included as a "file" for certain callbacks where it's necessary.Generally speaking, you'll be hard pressed to port everything to a theme. That is why they are a different extension type and why I created the Is Drupal Bootstrap a module or a theme? question of the FAQ section.
I was going to close this issue as "works as designed", but instead changing this to a documentation issue. This topic is one that really confuses people any why people constantly refer to this project as a "module" (one of my biggest pet peeves).
Perhaps we should also keep a running list of what alters are available as well?; in the
@BootstrapAlter
plugin docs maybe?Comment #3
sylus CreditAttribution: sylus commentedThank you so much for the through response! It definitely answered all of my questions and particularly described the intricacies / limitations with an explanation of why which I found helpful. This will save me a ton of work doing a re-write that just wouldn't have likely worked in any form.
I think this would be great information to spell out but am not sure where the correct place would be to document this. I was thinking perhaps the FAQ section, however due to verbosity maybe it would make sense to have a new page entirely? Will happily assist but for now can at least point people to this issue.
As for having a running list of the alters, I am definitely in favor of that.
Comment #4
markhalliwellActually, there's already a running list: http://drupal-bootstrap.org/api/bootstrap/docs%21plugins%21Alter.md/grou...
Comment #5
markhalliwell@sylus, any chance you could perhaps work on updating the documentation for this?
Comment #6
shelane