Currently the getFile() function returns a fixed path starting with '/libraries/. Similarly the getButtons() function returns a fixed path to the images starting with '/libraries'. This does not work when Drupal is installed at a subdirectory to the domain (e.g. http://localhost/drupal8/libraries).
I also found this is very similar to another project on github: https://github.com/wwalc/colorbutton. I suspect even shared the same start at some point. That code currently solves this with code like this:
function getFile() {
return drupal_get_path('module', 'colorbutton') . '/js/plugins/colorbutton/plugin.js';
}
Should this module and the one I found on github be merged or ??? I can copy/paste things and I'm willing to help but that doesn't mean I know what I'm doing. I'm certainly not capable of maintaining the module itself, but hoping that having found some simple fix is respectful of what you have done arleady and will make it easy for you to do a quick fix.
Comment | File | Size | Author |
---|---|---|---|
#11 | 2717655-path-cant-resolve-libraries-11.patch | 1.05 KB | kevinquillen |
#5 | 2717655-path-cant-resolve-libraries.patch | 506 bytes | kevinquillen |
Comments
Comment #2
carteriii CreditAttribution: carteriii commentedFor what it's worth, the addition of base_path() appears to fix the immediate problem I see:
It doesn't appear that Drupal 8 supports a call to drupal_get_path('library', 'colorbutton') which would have been even better than assuming the library is at the root level. I libraries module provides an API to get the library path but that seems like overkill to add the libraries module for this.
Comment #3
kevinquillen CreditAttribution: kevinquillen commentedHi carter, you are correct, I did see the other Color Button module and learned how to integrate plugins from that. I added in the ability to restrict colors from the admin and had future plans to also implement Color Panel as a sub module, as this was a recent requirement for a project. I did not put the plugins into the module because of the rules surrounding third party code packaged up within a Drupal module.
I don't think I have ever installed Drupal as a sub directory so I usually forget to do this. I will implement base_path() to resolve the issue.
Also, regarding Libraries, no I would prefer not to require a dependency to do this. libraries in the root is mentioned in the core documentation for this purpose, even if it is not auto-discoverable. In the future, if necessary, I will adapt to fit the need.
Comment #4
kevinquillen CreditAttribution: kevinquillen commentedComment #5
kevinquillen CreditAttribution: kevinquillen at Velir commentedAttaching patch
Comment #6
kevinquillen CreditAttribution: kevinquillen commentedComment #7
carteriii CreditAttribution: carteriii commentedThat same approach needs to be applied to getButtons. For example, this is what I did:
For what it's worth, this same/similar change needs to be applied to pannelbutton as well.
Comment #8
carteriii CreditAttribution: carteriii commentedI forgot to say, "Thank you!"
Comment #9
kevinquillen CreditAttribution: kevinquillen commentedShould it be base_path() or DRUPAL_ROOT?
Comment #10
kevinquillen CreditAttribution: kevinquillen commentedSee: http://stackoverflow.com/questions/3956435/what-is-the-correct-way-to-ob...
Comment #11
kevinquillen CreditAttribution: kevinquillen at Velir commentedUpdating patch
Comment #12
carteriii CreditAttribution: carteriii commentedI think base_path(), but I'm not 100% certain. Doesn't DRUPAL_ROOT include the server director? For example, would DRUPAL_ROOT return "/var/www/drupal8"? If so, we don't want that because we're trying to create a URL and the URL would never reference "/var/www". We really just want the "/drupal8" such that, if using localhost without any subdomain, the URL would be http://localhost/drupal8/.... You'd never want a URL that was "http://localhost/var/www/drupal8"
Comment #13
kevinquillen CreditAttribution: kevinquillen commentedAlright, lets go with this then. Just wanted to check.
Comment #14
kevinquillen CreditAttribution: kevinquillen commentedComment #16
kevinquillen CreditAttribution: kevinquillen at Velir commentedPushed to dev.
Comment #17
kevinquillen CreditAttribution: kevinquillen at Velir commented