|
| 1 | +--- |
| 2 | +title: Drupal |
| 3 | +--- |
| 4 | + |
| 5 | +# Drupal |
| 6 | + |
| 7 | +The [Drupal](https://drupal.org) integration relies on a contributed module called ["PartyTown"](https://drupal.org/project/partytown), which can either be installed manually, or by using composer. |
| 8 | + |
| 9 | +## Install |
| 10 | + |
| 11 | +### Using Composer |
| 12 | + |
| 13 | + 1. Use composer to download the Drupal module |
| 14 | + |
| 15 | +``` bash |
| 16 | +composer require drupal/partytown |
| 17 | +``` |
| 18 | + |
| 19 | + 2. Add the following code to your `composer.json` in the `repositories` section |
| 20 | + |
| 21 | +``` json |
| 22 | + |
| 23 | +partytown": { |
| 24 | + "type": "package", |
| 25 | + "package": { |
| 26 | + "name": "quickdev/partytown", |
| 27 | + "version": "0.11.0", |
| 28 | + "type": "drupal-library", |
| 29 | + "dist": { |
| 30 | + "url": "https://registry.npmjs.org/@qwik.dev/partytown/-/partytown-0.11.0.tgz", |
| 31 | + "type": "tar" |
| 32 | + }, |
| 33 | + "license": "MIT" |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +``` |
| 38 | + |
| 39 | + 3. Install the partytown JS library |
| 40 | + |
| 41 | +``` bash |
| 42 | +composer require quickdev/partytown |
| 43 | +``` |
| 44 | + |
| 45 | +### Using The Composer Merge Plugin |
| 46 | + |
| 47 | + 1. Use composer to download the Drupal module |
| 48 | + |
| 49 | +``` bash |
| 50 | +composer require drupal/partytown |
| 51 | +``` |
| 52 | + |
| 53 | + 2. If not already installed, install Merge Plugin: |
| 54 | + |
| 55 | +``` bash |
| 56 | +composer require wikimedia/composer-merge-plugin |
| 57 | +``` |
| 58 | + |
| 59 | + 3. Merge the PartyTown library from the module's `composer.json`: |
| 60 | + |
| 61 | + ``` bash |
| 62 | + composer config extra.merge-plugin.include --json '[ "web/modules/contrib/partytown/composer.libraries.json" ]' |
| 63 | + ``` |
| 64 | + |
| 65 | +### Manually |
| 66 | + |
| 67 | + 1. Download and unzip the Drupal module from the [PartyTown release page](https://www.drupal.org/project/partytown/releases) |
| 68 | + |
| 69 | + 2. Install the `partytown` directory in the Drupal `modules` directory (usually `<webroot>/modules` or `<webroot>/modules/contrib`) |
| 70 | + |
| 71 | + 3. Visit the Admin > Extend page of your Drupal installation and enable the PartyTown module |
| 72 | + |
| 73 | +## Configure |
| 74 | + |
| 75 | +All configuration for the PartyTown module takes place in the Drupal admin interface. You can manage most of the PartyTown API settings graphically at `/admin/config/development/partytown`. |
| 76 | + |
| 77 | +## Managing Scripts With PartyTown |
| 78 | + |
| 79 | +### Google Tag Manager |
| 80 | + |
| 81 | +The PartyTown module for Drupal comes with a submodule called "PartyTown Google Tag" for PartyTown-ing Google Tag Manager. Once installed, you will probably want to configure the PartyTown module to forward `dataLayer.push`. |
| 82 | + |
| 83 | +### Other scripts |
| 84 | + |
| 85 | +Other scripts can be PartyTown-ed by setting the type to be `text\partytown`. Using a `*.libraries.yml` this can be achieved with something similar to: |
| 86 | + |
| 87 | +``` yaml |
| 88 | +foo: |
| 89 | + js: |
| 90 | + js/foo.js: { attributes: { type: "text/partytown"} } |
| 91 | + |
| 92 | +``` |
0 commit comments