Although related to #909296: Figure out how to document what we've learned and discussed in detail

I'd like to specifically see some documentation on how to access css & js files that are in sites/all/libraries from the theme's .info file.

I would have expected I could pull it in with:
stylesheets[all][] = /sites/all/libraries/wet-boew-jquery/js/support/menubar/style.css

rather than:

stylesheets[all][] = ../../libraries/wet-boew-jquery/js/support/menubar/style.css

Thoughts would be appreciated.

#7 librariesmoduleinfo.patch2.93 KBRobLoach
PASSED: [[SimpleTest]]: [MySQL] 130 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


tstoeckler’s picture

Title: Documentation of Integration with Theme .info file » Allow to load libraries from an info file
Component: Documentation » Code
Category: task » feature

What you explain is currently not possible with Libraries API. That said, it definitely sounds like something we want to support. Not only themes, but also modules, which have external libraries as dependencies could benefit from this.
As we don't know the path to the library upfront (it doesn't always have to be sites/all/libraries), we can't support your code example directly, but I am thinking of something like:

libraries[] = menubar

(similar to dependencies[] for modules).

mgifford’s picture

Thanks @tstoeckler It would have to be more complicated than that however, as just including the library (like the dependancies) doesn't explain what files within the library would need to be included. I don't know if something like this would work:

libraries[wet-boew-jquery] = js/support/menubar/style.css

Or perhaps something like:

libraries[] = wet-boew-jquery
stylesheets[wet-boew-jquery]][] = js/support/menubar/style.css

I'd like to have some way for the theme to find the path and a way for the library code do recognize if the same file is loaded more than once by different modules/themes.

tstoeckler’s picture

Hmm.. we don't really support loading only parts of a library, what is the use-case for that?

mgifford’s picture

Well, let's say that the is a big library with a lot of code, say:

You want to use it in one or more themes, but don't want to embed it in your theme.

You may not want them at all times, but from time to time in a site.

RobLoach’s picture

mgifford’s picture

Title: Allow to load libraries from an info file » Allow ability to load libraries from an info file

Agreed, thanks!

RobLoach’s picture

Title: Allow ability to load libraries from an info file » Allow ability to load libraries from module .info files
Status: Active » Needs review
2.93 KB
PASSED: [[SimpleTest]]: [MySQL] 130 pass(es). View
name = Libraries test module
description = Tests library detection and loading.
core = 7.x
dependencies[] = libraries
hidden = TRUE

libraries[example_from_info][name] = Example from Info
libraries[example_from_info][vendor url] =
libraries[example_from_info][download url] =
libraries[example_from_info][version arguments][file] = README.txt
libraries[example_from_info][version arguments][pattern] = /Version (\d+)/
libraries[example_from_info][version arguments][lines] = 5
sun’s picture

Status: Needs review » Active

Hold on, #7 is quite against the principles of Libraries API - there's no correlation between modules and libraries for all the reasons being outlined on the project page - this patch basically adds support for modules to contain libraries?

Can we clarify the actual idea/proposal/question/issue in the summary first, please?

RobLoach’s picture

This patch basically adds support for modules to contain libraries?

Nope! This just pretty much lets you implement hook_libraries_info() via a module's .info file. Is that what you were talking about originally, mgifford?

mgifford’s picture

I don't want modules to contain libraries. I see real advantages to separating 3rd party software in a common, understood location rather than having it be scattered around

However, I guess I'd like to extend the definitions of libraries a bit so that one can not just point to a CCK (a book), but in the module pick out a specific CSS or JS file (one of a collection of journals) to load.

This could be in either the module or theme .info file, but we shouldn't be needing to either hard code a relative path to a specific file that is contained in a 3rd party library, or just copy/paste that 3rd party file into the theme or module we're building.

We should be able to set a dependancy library (either a book or a journal) in the .info file and then load either the whole 3rd party resource or a specific file within that resource.

I'm just looking at

That's probably more than I was looking for, but since it's already there it may well be able to do what's required.

tstoeckler’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing this one.

In the 8.x-3.x we are striving for the ability to simply declare the name of a library in the info file, and have Libraries API take care of the rest.

You can already provide libraries in (their own) info files and even put those into a module as well using hook_libraries_info_file_paths(). I don't see much value pursuing this, at this point.

Please re-open if there is still interest in this, or if there is an aspect I have missed.