- Issue created by @Liam Morland
- 🇨🇦Canada jmdeleon
Hi liam,
The support for datatables.net was contributed from an outside contributor to the module. Supporting a local copy of the DataTables libraries can certainly be looked into (contributions welcome). General support for DataTables is a low priority in terms of maintenance of this project, but again contributions are welcome.
If you're using the Web Experience Toolkit (WxT), tables can be adapted to use the DataTables plugin integrated into the WxT, by adding the class "wb-tables" to the table element. Adding CSS classes to elements of the generated table (table, headers, rows) is already supported in the field formatter configuration.
- Merge request !20Issue #3520780: Allow local DataTables library, avoiding CDN → (Merged) created by Liam Morland
-
liam morland →
committed 5788da8d on 1.0.x
Issue #3520780: Allow local DataTables library, avoiding CDN
-
liam morland →
committed 5788da8d on 1.0.x
- 🇨🇦Canada jmdeleon
I'm trying to test the changes here.
The ZIP file download produced here:
https://datatables.net/download
contains CSS and JS files that (minimally) aren't named the same as the files listed in definition of the datatables_local library, in the updated csvfile_formatter.libraries.yml configuration.
When I went to produce a ZIP file from the DataTables.net download link, the ZIP file returned had files named datatables.min.css and datatables.min.js, with no folder structure (no "media" folder) which don't match the paths described in the datatables_local library.
Some documentation/explanation is going to be needed on how you are loading the DataTables JS and CSS files into the local libraries folder.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
We have it installed with this in the Composer
require
section:"datatables/datatables": "^1.10",
This is in the
extra
,installer-paths
section:"html/libraries/{$name}": [ "datatables/datatables", "type:drupal-library" ],
This is what we already had.
- 🇨🇦Canada jmdeleon
Post the instructions here and we can work out how to best put it into the README.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
The DataTables library can be installed with:
composer require 'datatables/datatables:^1.10'
You will probably need to update your
composer.json
file by adding the following in theextra
,installer-paths
section:"web/libraries/{$name}": [ "datatables/datatables", "type:drupal-library" ],
If you are installing a different way, you may need to change the file names and locations from what is in
csvfile_formatter.libraries.yml
. You can do that withhook_library_info_alter()
. - 🇨🇦Canada jmdeleon
https://packagist.org/packages/datatables/datatables
The DataTables package imported by composer is a legacy repo, of a version of DataTables that's even older than the one brought in by the CDN in the current version of the module.
The packagist.org page even suggests going to the DataTables download builder to get the latest version.
I'm in favour of going to the official download builder and copying the CSS and JS to libraries/datatables , even if that means not using composer.
Started a new branch with a suggested fix. Also took the time to update the version picked up by the module from the CDN.
- Merge request !21update:DataTables latest from CDN,simplify library usage → (Merged) created by jmdeleon
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I just pushed to the issue fork a commit updating the
version
key to match the changes. I will test this. - Merge request !22update:documentation for CDN or local libraries usage → (Merged) created by jmdeleon
- 🇨🇦Canada jmdeleon
Hi @liam morland , no I don't have the composer installation working. Quite frankly, I don't trust an unmaintained five-year-old archived repository.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I have it working now on version 2.2.2 using the Composer instructions from the bottom of this page:
https://datatables.net/download/
I had the change the file paths, see branch
3520780-composer
. - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
Updated draft for documentation:
The DataTables library can be installed with:
composer require 'datatables.net/datatables.net-dt:^2.2'
You will probably need to update your
composer.json
file by adding the following in theextra
,installer-paths
section:"web/libraries/{$name}": [ "datatables.net/datatables.net", "datatables.net/datatables.net-dt", "type:drupal-library" ],
If you are installing a different way, you may need to change the file names and locations from what is in
csvfile_formatter.libraries.yml
. You can do that withhook_library_info_alter()
. - 🇨🇦Canada jmdeleon
Hi liam,
I tried issuing the composer require command from the DataTables download page, and made your edits to composer.json .
The DataTables JS and CSS ended up in the vendor directory, not the web/libraries directory.
I tried these steps on a clean Drupal 11 and Drupal CMS install.
Below are the steps I was able to take to add the DataTables JS and CSS to web/libraries :
Add the following snippet to the "repositories" section of your composer.json:
```
"datatables": {
"type": "package",
"package": {
"name": "csvfile_formatter/datatables",
"version": "2.2.2",
"type": "drupal-library",
"dist": {
"url": "https://datatables.net/download/builder?dt/dt-2.2.2",
"type": "zip"
}
}
}
```After adding the snippet above to the "repositories" section of composer.json, import the DataTables JS and CSS through composer:
```
composer require csvfile_formatter/datatables
```This worked on a clean Drupal 11 and Drupal CMS install.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I thought that
datatables
wasn't mandatory forcsvfile_formatter
. If so, we would expect people to install it via their own Composer files instead of it being always installed withcsvfile_formatter
. - 🇨🇦Canada jmdeleon
@liam: I tried both of your steps in #11 and #19, and neither of those steps placed DataTables files in the web/libraries folder that could be loaded when the DataTables settings on the field was set to "Load from local files".
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
It looks like you need to have
composer/installers
installed for theinstaller-paths
key to work. - 🇨🇦Canada jmdeleon
composer/installers is included in composer.json for Drupal 11 and CMS.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
We also have
mnsami/composer-custom-directory-installer
installed. Maybe that is is needed. - 🇨🇦Canada jmdeleon
"We also have mnsami/composer-custom-directory-installer installed. Maybe that is is needed."
We have a winner!
This was the sequence of steps I took to get the datatables.net and datatables.net-dt folders into the local libraries folder:
Issue:
composer require mnsami/composer-custom-directory-installerAdd the following under "extra", "installer-paths" in composer.json:
"web/libraries/{$name}": [
"datatables.net/datatables.net",
"datatables.net/datatables.net-dt",
"type:drupal-library"
],Issue:
composer require datatables.net/datatables.net-dtThis worked for Drupal 11 and CMS. The csvfile_formatter module in your branch 3520780-composer then works with the setting "Load from local files" selected.
This should be documented a bit more cleanly, as I intend to include it on the project page.
- 🇨🇦Canada jmdeleon
@liam I pushed your branch
3520780-composer
with the change to csvfile_formatter.libraries.yml to 1.0.x-dev for testing.I'd like some documentation written up for loading the DataTables libraries (based on the steps in #26) and add it to the README, before making a release.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I have added instructions to branch
3520780-composer
. -
liam morland →
committed c57e614f on 1.0.x
Issue #3520780: Update Composer instructions for installing the...
-
liam morland →
committed c57e614f on 1.0.x
- 🇨🇦Canada jmdeleon
@liam Thanks! I made a couple more adjustments to the documentation and committed that to 1.0.x-dev
This should be pretty close to what I'd be happy to release. I'll update the project page accordingly upon release.
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I just added a spelling exception needed by my recent change.
-
liam morland →
committed 89877e0f on 1.0.x
Issue #3520780: Add spelling exception
-
liam morland →
committed 89877e0f on 1.0.x