Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add the require jquery cycle library in composer json file.
Comment | File | Size | Author |
---|---|---|---|
#39 | views_slide_show_cycle__manage_assets_dependencies.patch | 3.54 KB | dhim712 |
| |||
#38 | 2673910-38.patch | 6.6 KB | AlexBorsody |
| |||
#29 | 2673910.patch | 1003 bytes | tamerzg |
Comments
Comment #2
heykarthikwithuComment #4
heykarthikwithuComment #5
NickDickinsonWildehmm I can't find this; what repository is it in? not the drupal packagist nor the standard one as far as I could find.
Comment #6
heykarthikwithuComment #7
heykarthikwithuIt was a mistake, cycle doesn't exist in the packagist.org
Have an other way around, which i have implemented in Imagefield Slideshow module.
On composer update, it gets the cycle library and place in the vendor directory, which is been written in patch.
Comment #8
NickDickinsonWildeI'll try it out, thanks!
Comment #12
NickDickinsonWildeOh well got a slight problem... like it won't work with that method: Composer doesn't allow it
So back to the drawing board on that one... Guess we need cycle on packagist; want to investigate that or want me to?
Thanks
Comment #13
NickDickinsonWildeComment #15
heykarthikwithuThis should help for having the cycle library,
https://www.drupal.org/node/2818159#comment-11771551
https://packagist.org/packages/heykarthikwithu/cycle
Comment #16
vbouchetWill it be possible to add the source repository directly into the composer.json instead of using a third-party packagist not maintained by the Jquery cycle plugin maintainer ?
Something like:
Comment #17
NickDickinsonWilde@vbouchet: unfortunately not. Composer doesn't let packages define repositories. The reasons make sense (mostly performance), so annoying but not really work aroundable.
Comment #18
ashleyhazle CreditAttribution: ashleyhazle as a volunteer and commented@nickwhilde, in my sites composer I have taken a leaf out of the webform module's book and included the following:
As per @vbouchet, wouldn't something like this be preferable to a third-party packagist?
There's also something that can be done with Git using `source` instead of `dist`, but I'm not sure how that works…
Comment #19
NickDickinsonWildeUnfortunately, we can't directly include a new repository definition in a composer.json that's included in other projects. As a security feature, that's blocked except in the top level composer.json
Comment #20
ñull CreditAttribution: ñull commentedJust putting in my two cents.
3 of the 4 libraries appear as Bower assets that can be installed and maintained in composer with the fxp/composer-asset-plugin:
Unfortunately the last library, tobia/Pause , is missing. May be because it is already 8 years old? May be time to either choose an alternative that is available as npm or bower asset? Or may be someone who knows how to do can make it available as such?
Comment #21
auxiliaryjoel CreditAttribution: auxiliaryjoel commentedIs there currently any way to use composer to manage/install the 4 javascript libraries ?
e.g.:
jQuery Cycle 3.x in /libraries/jquery.cycle
JSON2 in /libraries/json2
jQuery HoverIntent in /libraries/jquery.hoverIntent
jQuery Pause in /libraries/jquery.pause
or do I have to install them via other methods?
(note: I'm using Drupal 8, subtheme of Bootstrap 4 with composer controlling drupal/modules)
Comment #22
ñull CreditAttribution: ñull commented@auxiliaryjoel like said, three are possible with the #20 indicated method, but pause would need to be added like in #18. It does not stop there however. The use of dots is not standard composer paths. So the module needs to be patched to (also) recognise these newer library paths.
Comment #23
ñull CreditAttribution: ñull commentedBased on version 4.6 of this module, here a fragment of my composer.json that works fine here to include the libraries, where the dotted lines indicate the parts I have removed for clarity.
Comment #24
auxiliaryjoel CreditAttribution: auxiliaryjoel commented@ñull Thanks for the info ñull I will try and wrap my head around this and see if I can get it working as per your suggestion.
Comment #25
Petr Illek@ñull Thank you for the snippet.
Few question though:
* What is the
"oomphinc/composer-installers-extender": "^1.1"
for? It is working without it for me.* Are the lines in installer-path section
"web/libraries/jquery.cycle": ["malsup/cycle"], "web/libraries/jquery.hoverIntent": ["briancherne/jquery-hoverintent"], "web/libraries/json2": ["douglascrockfordmalsup/json-js"]
necessary? They all have specified "type":"drupal-library" in the repository part, so they will follow"web/libraries/{$name}": ["type:drupal-library"]
, and end up in libraries?Comment #26
ñull CreditAttribution: ñull commented@Petr Illek you are probably right that both are not needed and left overs from former attempts. Please test your second assumption for me and I will clean up my post accordingly!
Comment #27
sitiveni CreditAttribution: sitiveni commented@Petr Illek Yes, the installer-path section is necessary. If not there it'll install the libraries using the name of the repository library. This would end up like this:
Adding the installer paths let's us control the names of directory so it matches with what the code expects.
To clarify, this is the intended library folder structure for the 3 libraries:
Comment #28
Petr Illek@sitiveni Thank you for the explanation.
Comment #29
tamerzg CreditAttribution: tamerzg at Websolutions Agency commentedCurrently most popular way to load 3rd party libraries while using composer is asset packagist which allow us to add bower and npm assets (more about that: https://drupalize.me/tutorial/composer-configuration-drupal?p=3233). As mentioned by @null in #20 there are 3 out of the 4 libraries appear as Bower assets that can be installed and maintained in composer.
Missing library is tobia/Pause, because it doesn't have github realease or the tag (it also must be per semantic versioning). Since this library is 8 years old, I forked it, created proper tag and then registered it on Bower.
Therefore now its possible to install all 4 required libraries via composer:
However another issue arise, its the directory naming for jquery-cycle and jquery-hoverintent. This module is looking for those libraries in these directories:
/libraries/jquery.cycle
/libraries/jquery.hoverIntent
but composer installs them in these:
/libraries/jquery-cycle
/libraries/jquery-hoverintent
Since those namings are coming from authors themselves and are registered like that on bower, I think we need to change it in this module.
https://asset-packagist.org/package/bower-asset/jquery-cycle
https://asset-packagist.org/package/bower-asset/jquery-hoverintent
Therefore I attached a patch.
Comment #30
RedEight CreditAttribution: RedEight at 95Visual commentedI ran into an issue while following the steps in #29. When running
composer require bower-asset/json2
I get the following errorAny idea what could be causing this? It seems like it went ahead and installed it when I said yes.
Comment #31
RedEight CreditAttribution: RedEight at 95Visual commented[removed duplicate]
Comment #32
allella CreditAttribution: allella as a volunteer commentedI was able to resolve the following issues using the steps below.
Issues Resolved
Step 1 - General Notes About Editing composer.json
Step 2 - "installer-types" and "installer-paths" Modifications in composer.json
We update the composer.json file (in the same directory as vendor/) "extra" section to include custom "installer-types" and "installer-paths" below.
If you have an existing "extra" section then merge these "installer-paths" additions ABOVE the existing "installer-paths" lines to avoid potentially conflicting definitions, as described in mautumn's comment #33.
You should adjust the paths if your public Drupal doesn't exist in web/ directory . For example, you likely need to remove the "web/" part of the installer-paths if you didn't use drupal-composer/drupal-project to install your site.
This will fix the path directory issue (using . instead of -) mentioned in #29, but these changes don't do anything until we install the associated packages in a later step.
The renaming trick is made possible by composer/installers (installed below) + oomphinc/composer-installers-extender (installed below) + the tweak outlined under "Installing a custom path".
Step 3 - "repositories" Section Modifications in composer.json
We will now register Asset Packagist as a new Composer repository. This avoids having to manually register and maintain every JS package as its own repository, as proposed in #23.
This example assumes your composer.json file (in same directory as vendor/) already had 1 existing repository, called https://packages.drupal.org/8. If so, then merging in a second under repositories would look like:
Step 4 - Install Required, Support Packages via Composer
The following Composer packages are needed before we actually are able to download the Javascript packages and do the install directory / path renaming tricks.
In the command line project root directory (where vendor/ exists), run:
Step 5 - Making composer.json Recognize the New 'Asset Packagist' Bower Repository
I tried a bunch of things, but it was necessary to delete the composer.lock and re-install before Composer would recognize the new https://asset-packagist.org repository.
In the command line project root directory (where vendor/ exists), run:
Step 6 - Use Composer to Install Views Slide and Its Required Javascript Packages
If everything above worked, then it's now possible to install the Bower-based Javascript packages through Composer, via the new Asset Packagist repository.
The packages will be installed in a custom, public Drupal libraries/ directory using the renaming tricks described above.
Create a libraries/ directory (web/libraries/ for drupal-composer/drupal-project users), which is where Composer will install the Javascript packages.
On the command line, in the public Drupal directory run:
mkdir libraries/
On the command line, in the project root directory (where vendor/ exists), run:
When the installs finish these JS packages should be in the public Drupal libraries/ directory, NOT vendor/.
You can check by running the following (from the public Drupal directory) and you should see directories for each of the 4 bower-asset packages above.
It's important the first 3 directories here show a . (period) in the name, because this Drupal Views Slideshow module expects periods, not dashes.
Step 7 - Enable Views Slideshow
This assumes you're using Drush on the command line. I used "default" as the URI, but you'll need to use your domain if you have a custom configuration directory besides the default /sites/default/.
On the command line, in the project root directory (where vendor/ exists), do the following:
Enable the Views Slideshow modules
Clear the Drupal cache if you have any issues.
Comment #33
mautumn CreditAttribution: mautumn as a volunteer commentedHi @allella, thanks very much for your very detailed and useful write up in #32. It worked for me except for one tiny assumption that didn't hold with my composer.json file. I'll share it here in case it helps others.
The extras -> installer-paths of my composer.json looked like this initially :-
and I simply added the required libraries at the end like this :-
However, his didn't work for me because both composer require 'bower-asset/jquery-hoverintent' and composer require 'bower-asset/jquery-cycle' ended up in dash-named libraries directories - rather than the required dot-named directories.
The cause of this was simply due to the presence of the wildcard libraries directive "web/libraries/{$name}" taking precedence over the new lines I naively appended to the end. These later lines were never reached (composer resolved these libraries via the earlier wildcard directive) and so the default name of the original library names were used.
The solution was simply to place the new library directives above the wildcard section as follows :-
Many thanks to all who have worked on this great module.
Comment #34
allella CreditAttribution: allella as a volunteer commented@mautumn, yes, that makes sense, except I don't think it would be an issue if the following were removed:
from composer.json
My composer.json is based on drupal-composer/drupal-project and doesn't map bower-asset or npm-asset to libraries,
so I didn't experience this issue.
Out of curiosity, were those extra types copied from #20?
Nonetheless, I've added a word of caution to #32.
Thanks
Comment #35
mautumn CreditAttribution: mautumn as a volunteer commentedHi @allella,
Yes, I didn't expect everyone to experience the issue I had - it obviously depends on one's composer.json contents - and there are probably as many different flavours of these as there are Drupal developers!
No I didn't copy anything from #20. Mine is a relatively new site and I can't remember where I picked up
The fact that I had these two lines and #20 did as well suggests that it is not particularly uncommon - hence why I posted my piece. And, yes, without these two lines, there shouldn't be a problem and my work-around shouldn't be necessary.
Your word of caution in #32 is good advice.
Thanks
Comment #36
natts#32 has generally worked for me, but I needed to modify this:
composer require "oomphinc/composer-installers-extender:^1.1"
to simply this:
composer require "oomphinc/composer-installers-extender"
which installed v1.1.2 instead, due to this version conflict:
Comment #37
allella CreditAttribution: allella as a volunteer commentedThanks Natt #32 has been updated.
Comment #38
AlexBorsody CreditAttribution: AlexBorsody at Busy Pixel Media commentedThis patch also changes the paths to what is used when required by composer, I am also removing
jquery-hoverintent
, it's extra js that just slows my page and isn't needed. Otherwise It's similar to #29 where.
is replaced with-
in the path.Comment #39
dhim712 CreditAttribution: dhim712 commentedHere a patch with the composer.libraries.json solution.
Here the process to follow up: https://www.drupal.org/docs/8/modules/webform/webform-frequently-asked-q...
Comment #40
Matt BFollowing #32, I kept getting:
So I removed the line
"installer-types": ["bower-asset", "npm-asset"],
and it then worked fine, but the JS was not in the libraries folder.I tried making the change in #32:
I also tried removing the bower-asset packages and adding them again, and it's still not putting the JS in the libraries folder.
Comment #41
zrodimel CreditAttribution: zrodimel commentedI'm getting the same error as #40 when following #32. Does anyone know of an updated solution to this?
Comment #42
allella CreditAttribution: allella as a volunteer commented@zrodimel I don't recall everything about how this works, but here are earlier notes I shared about the overall process
https://www.drupal.org/project/entityqueue/issues/2638682#comment-12294259
Comment #43
munchmunch CreditAttribution: munchmunch commented@zrodimel @Matt B I ran into the same issue when following #32 and found the problem to be related to #33. For me, I needed to have both the wildcard and the explicit installer-paths:
(json2 and jquery.pause don't need to be explicitly listed since they aren't being renamed)
My guess is that composer refuses to continue without a way to handle generic bower-assets and npm-assets. This is also the official suggestion by Drupal by the way: https://www.drupal.org/docs/develop/using-composer/manage-dependencies#t...
secondly, for whatever reason my site appears to work fine without bower-asset/bootstrap or npm-asset/jquery--i do have these drupal/jquery_* modules installed though:
lastly, i had to specify the json2 dev version:
composer require 'bower-asset/json2:*@dev'
speaking of which, i wonder if it'd be a good idea to switch the bower packages to npm versions.. though at least for json2 that isn't currently possible since asset-packagist.org seems to ignore case sensitivity (npm-asset/json is not differentiated from npm-asset/JSON even though they are different packages on npmjs.com).
Comment #44
allella CreditAttribution: allella as a volunteer commentedIt may be the case the bower-asset/json2 package only has a dev branch now.
https://asset-packagist.org/package/bower-asset/json2
Also, the top of the Bower site says
so it would seem Bower is depreciating itself and the #43 suggest to switch to another package source or repo, perhaps yarn over npm, may resolve the issue.
If that's the case, I can update #32 to reflect the change if someone wants to test and post a suggestion. This is for an old client site that I no longer support, so I don't have an easy way to validate the changes.
Comment #45
NickDickinsonWildeI've gone the same way as webform - composer merge plugin - https://git.drupalcode.org/project/views_slideshow/-/blob/5.0.x/README.m.... There is a breaking change from libraries/jquery.hoverIntent to libraries/jquery.hover-intent for the one library.