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!

Comments

pglatz created an issue. See original summary.

yoruvo’s picture

It 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.

jonhattan’s picture

Version: 8.x-1.9 » 8.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new554 bytes

It's enough to use the absolute path to the file.

gokulnk’s picture

Status: Needs review » Reviewed & tested by the community

I agree that using the absolute path to the file is sufficient.

dave reid’s picture

Will this work if Drupal is installed in a subdirectory though?

eme’s picture

Maybe we shloud ship the file into the module to reach certainty ?

jonhattan’s picture

@DaveReid I guess yes, as far as you've configured the RewriteBase accordingly

Kazanir’s picture

No, it won't. RewriteBase doesn't help with static assets since they are typically excluded from any rewriting in the first place.

gokulnk’s picture

Since 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

bradjones1’s picture

Status: Reviewed & tested by the community » Needs work

The absolute path is just as bad as the broken relative path, just in a different way.

bruvers’s picture

Category: Support request » Bug report
Status: Needs work » Needs review
StatusFileSize
new1.42 KB

Absolute 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.

Status: Needs review » Needs work

The last submitted patch, 11: admin_toolbar-add_chevron_icon_from_core-2552081-11.patch, failed testing.

bradjones1’s picture

Status: Needs work » Needs review

This doesn't appear to be a problem with the patch but the CI engine... resetting status to queue again.

Status: Needs review » Needs work

The last submitted patch, 11: admin_toolbar-add_chevron_icon_from_core-2552081-11.patch, failed testing.

  • eme committed af273e8 on 8.x-1.x authored by bruvers
    Issue #2552081 by jonhattan, bruvers: chevron-right.svg not found
    
eme’s picture

Status: Needs work » Fixed

Seems to work well. Commited then.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.