I'm just getting started with Drupal 8, and am trying to understand how paths are used with the new version.
I installed admin_toolbar in the /modules directory
Then I decided to do the kind of organization I do in Drupal 7, which I would create a sites/all/modules/contrib directory for contrib modules, and sites/all/modules/custom directory for modules I develop for a specific project.
So I created /modules/contrib, and moved admin_toolbar there. I also ran drush cr, just in case there were changes that needed to be resolved in the registry.
The module works, but I'm seeing the error page not found: /modules/core/misc/icons/0074bd/chevron-right.svg in watchdog. I noticed that the path to the background image is hard coded to '../../../core/misc/icons/0074bd/chevron-right.svg' in admin.toolbar.css
This makes it seem that the module can only be installed in the /modules directory - is this correct? Is this true for all contrib modules? Is specifying a relative path to the icons good practice? This breaks when the module is placed at a different directory level. I'm used to creating paths programmatically in Drupal 7, but don't know how this could be done in a css file.
I also noted there is a version of chevron-right.svg in /core/misc/icons/000000 -- I don't understand what's up with the various subdirectories under misc/icons, can you point me to a resource that explains this.
Thanks - I'm enjoying learning about Drupal 8, but there is sure a lot to learn!
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | admin_toolbar-add_chevron_icon_from_core-2552081-11.patch | 1.42 KB | bruvers |
| #3 | 2552081-admin_toolbar-chevron-right.svg-not-found.patch | 554 bytes | jonhattan |
Comments
Comment #2
yoruvo commentedIt is definitely not the case that all contrib modules must be installed directly under the /modules directory. For instance, it is common practice to separate contrib modules and your custom modules into /modules/contrib and /modules/custom, respectively.
The CSS seems less than advantageous and should be corrected, for instance by copying the SVG into the module, or moving the background-image into inline styling.
Comment #3
jonhattanIt's enough to use the absolute path to the file.
Comment #4
gokulnk commentedI agree that using the absolute path to the file is sufficient.
Comment #5
dave reidWill this work if Drupal is installed in a subdirectory though?
Comment #6
eme commentedMaybe we shloud ship the file into the module to reach certainty ?
Comment #7
jonhattan@DaveReid I guess yes, as far as you've configured the RewriteBase accordingly
Comment #8
Kazanir commentedNo, it won't. RewriteBase doesn't help with static assets since they are typically excluded from any rewriting in the first place.
Comment #9
gokulnk commentedSince it may not be a good practice to use php within css file, I think it would be better to ship this file with the module. But then it would defeat the purpose of reusing the existing file that comes with Drupal Core. So I a not sure which was is better :P
Comment #10
bradjones1The absolute path is just as bad as the broken relative path, just in a different way.
Comment #11
bruvers commentedAbsolute paths and relative paths both do not work. A simple solution is to include the icon from core. Bundling the file with the module makes it also a tiny bit more independent from the core module.
Can we include the icon and fix this issue? Once a better solution is found a new issue can be created.
Comment #13
bradjones1This doesn't appear to be a problem with the patch but the CI engine... resetting status to queue again.
Comment #16
eme commentedSeems to work well. Commited then.