Difference between revisions of "Drupal"

From Wasya Wiki
Jump to: navigation, search
(Install & Configure)
 
(68 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
   
 
   
== Install & Configure ==
+
= Install & Configure =
  
 
   composer create-project drupal/recommended-project:9.5.10 html
 
   composer create-project drupal/recommended-project:9.5.10 html
Line 6: Line 6:
 
   composer require 'drupal/devel:^5.1'
 
   composer require 'drupal/devel:^5.1'
 
   composer require 'drupal/s3fs:^3.3'
 
   composer require 'drupal/s3fs:^3.3'
   composer require 'wasya-co/consent_popup: 1.0.4.x-dev'
+
   # composer require 'wasya-co/consent_popup: 1.0.4.x-dev'
   composer require drush/drush ## installed version ^11.6
+
   composer require 'drupal/consent_popup:^1.0'
 +
  composer require 'drush/drush:^11.6'
 
   composer require 'drupal/metatag:^2.0'
 
   composer require 'drupal/metatag:^2.0'
 
   composer require 'drupal/redirect:^1.9'
 
   composer require 'drupal/redirect:^1.9'
Line 13: Line 14:
 
   composer require 'drupal/webform:^6.0'
 
   composer require 'drupal/webform:^6.0'
 
   composer require 'drupal/captcha:^1.14'
 
   composer require 'drupal/captcha:^1.14'
 +
  composer require 'drupal/typed_data:^1.0@alpha'
 
   composer require 'drupal/rules:^3.0@alpha'
 
   composer require 'drupal/rules:^3.0@alpha'
 +
  composer require 'drupal/smtp:^1.2'
 +
  composer require 'drupal/hal:^1.0'
 +
  composer require 'drupal/restui:^1.21'
 +
  composer require 'drupal/keycloak:^2.2@beta'
 +
  composer require 'drupal/nodeaccess:^2.0@alpha'
 +
  composer require 'drupal/backup_migrate:^5.0'
 +
  composer require 'drupal/email_registration:^2.0@RC'
 +
  composer require 'drupal/content_access:^2.0'
 +
  composer require 'drupal/social_media:^2.0'
 +
  composer require 'drupal/wordpress_migrate:^3.0@alpha'
 +
  composer require 'drupal/migrate_tools:^6.0'
 +
  composer require 'drupal/codefilter:^2.0'
 +
  composer require 'drupal/views_taxonomy_term_name_depth:^7.2'
 +
  composer require 'drupal/calendar_view:^2.1'
 +
    composer require 'drupal/pathauto:^1.12'
 +
  composer require 'drupal/metatag:^2.0'
 +
  composer require 'drupal/twig_tweak:^3.3'
 +
  composer require 'drupal/simplenews:^4.0'
 +
    # composer require 'drupal/migrate_plus:^6.0' ## didn't need it the second time
 +
  composer require 'drupal/ctools:^4.0'
 +
  composer require 'drupal/commerce:^2.40'
 +
    composer require drupal/inline_entity_form @RC --no-update
 +
    apt install php-bcmath php8.1-bcmath
 +
    composer require 'drupal/commerce_stripe:^1.1'
 +
  composer require 'drupal/linkit:^6.0'
 +
  composer require 'drupal/redirect_after_login:^3.0'
 +
  composer require 'drupal/symfony_mailer:^1.4'
 +
  composer require 'drupal/custom_search:^1.0@beta'
  
 
+
== in review ==
 
+
 
+
  composer require drupal/core-recommended:8.8.2 drupal/core-composer-scaffold:8.8.2 drupal/core-project-message:8.8.2 --update-with-all-dependencies
+
  
 +
anywhere:
  
 +
  composer require 'drupal/seo_checklist:^5.2'
  
 +
  composer require 'drupal/yoast_seo:^1.9'
  
=== doesn't work ===
+
== upgrade 9 -> 10 ==
 +
* https://piousbox.com/update.php
  
 +
* https://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-or-later/how-to-upgrade-from-drupal-9-to-drupal-10
 +
* https://www.drupal.org/project/upgrade_status
  
   composer require 'drupal/formblock:^2.0@beta'
+
   composer require 'drupal/core-recommended:^10' 'drupal/core-composer-scaffold:^10' 'drupal/core-project-message:^10' --no-update
  
 
== Configure Apache ==
 
== Configure Apache ==
Line 74: Line 107:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
= Develop =
 +
 +
* various dumpers like dpm: https://www.drupal.org/project/vardumper
 +
 +
  $renderer = \Drupal::service('renderer');
 +
    $renderer->addCacheableDependency($build, $config);
 +
    $renderer->addCacheableDependency($build, $cu);
 +
  $config = \Drupal::config('system.site');
 +
  $current_user = \Drupal::currentUser();
 +
    $cu = \Drupal\user\Entity\User::load($current_user->id())
 +
 +
== use drush ==
 +
 +
  ./vendor/bin/drush --version
 +
  ./vendor/bin/drush cache:clear
 +
  ./vendor/bin/drush updatedb:status  -vvv
 +
 +
  drush entity:updates
  
 
== Disable caching ==
 
== Disable caching ==
 +
 
From: https://www.drupal.org/docs/develop/development-tools/disable-caching
 
From: https://www.drupal.org/docs/develop/development-tools/disable-caching
  
Line 92: Line 145:
 
     class: Drupal\Core\Cache\NullBackendFactory
 
     class: Drupal\Core\Cache\NullBackendFactory
 
</pre>
 
</pre>
 +
 +
== ReST ==
 +
<pre>
 +
 +
 +
curl --include \
 +
  --request POST \
 +
  --user admin:<> \
 +
  --header 'Content-type: application/hal+json' \
 +
  http://pi.local/node?_format=hal_json \
 +
  --data-binary '{
 +
    "_links": {
 +
      "type":{"href":"http://pi.local/rest/type/node/article"}
 +
    },
 +
    "title":[{"value":"Node +++ 123 bac +++" }],
 +
    "body":[{"value": "<b>hello, wor</b>ld!", "format": "full_html" }],
 +
    "type":[{"target_id":"article"}],
 +
    "status": [{"value": 1}],
 +
    "_embedded": {
 +
      "http://pi.local/rest/relation/node/article/field_issue": [
 +
        { "uuid": [{ "value": "56229a95-d675-43e1-99b1-f9e11b5579c5" }] }
 +
      ],
 +
      "http://pi.local/rest/relation/node/article/field_tags": [
 +
        { "uuid": [{ "value": "45646a7d-1a16-42e8-b758-f6e1c8d976f7" }] },
 +
        { "uuid": [{ "value": "834e34e2-05ae-498d-b876-453798872ce1" }] }
 +
      ]
 +
    }
 +
 +
  }'
 +
</pre>
 +
 +
= Tutorials =
 +
* routing
 +
** https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-routes
 +
* https://drupal.stackexchange.com/questions/87234/get-term-name-for-page-title-from-term-id-passed-in-the-contextual-filter
 +
* https://www.drupal.org/docs/drupal-apis/routing-system/introductory-drupal-routes-and-controllers-example

Latest revision as of 16:51, 11 November 2024

Install & Configure

 composer create-project drupal/recommended-project:9.5.10 html
 composer require 'drupal/devel:^5.1'
 composer require 'drupal/s3fs:^3.3'
 # composer require 'wasya-co/consent_popup: 1.0.4.x-dev'
 composer require 'drupal/consent_popup:^1.0'
 composer require 'drush/drush:^11.6'
 composer require 'drupal/metatag:^2.0'
 composer require 'drupal/redirect:^1.9'
 composer require 'drupal/superfish:^1.6'
 composer require 'drupal/webform:^6.0'
 composer require 'drupal/captcha:^1.14'
 composer require 'drupal/typed_data:^1.0@alpha'
 composer require 'drupal/rules:^3.0@alpha'
 composer require 'drupal/smtp:^1.2'
 composer require 'drupal/hal:^1.0'
 composer require 'drupal/restui:^1.21'
 composer require 'drupal/keycloak:^2.2@beta'
 composer require 'drupal/nodeaccess:^2.0@alpha'
 composer require 'drupal/backup_migrate:^5.0'
 composer require 'drupal/email_registration:^2.0@RC'
 composer require 'drupal/content_access:^2.0'
 composer require 'drupal/social_media:^2.0'
 composer require 'drupal/wordpress_migrate:^3.0@alpha'
 composer require 'drupal/migrate_tools:^6.0'
 composer require 'drupal/codefilter:^2.0'
 composer require 'drupal/views_taxonomy_term_name_depth:^7.2'
 composer require 'drupal/calendar_view:^2.1'
   composer require 'drupal/pathauto:^1.12'
 composer require 'drupal/metatag:^2.0'
 composer require 'drupal/twig_tweak:^3.3'
 composer require 'drupal/simplenews:^4.0'
   # composer require 'drupal/migrate_plus:^6.0' ## didn't need it the second time
 composer require 'drupal/ctools:^4.0'
 composer require 'drupal/commerce:^2.40'
   composer require drupal/inline_entity_form @RC --no-update
   apt install php-bcmath php8.1-bcmath
   composer require 'drupal/commerce_stripe:^1.1'
 composer require 'drupal/linkit:^6.0'
 composer require 'drupal/redirect_after_login:^3.0'
 composer require 'drupal/symfony_mailer:^1.4'
 composer require 'drupal/custom_search:^1.0@beta'

in review

anywhere:

 composer require 'drupal/seo_checklist:^5.2'
 composer require 'drupal/yoast_seo:^1.9'

upgrade 9 -> 10

 composer require 'drupal/core-recommended:^10' 'drupal/core-composer-scaffold:^10' 'drupal/core-project-message:^10' --no-update

Configure Apache

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Configure s3fs

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement0",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:ListBucketVersions"
            ],
            "Resource": [
                "arn:aws:s3:::<ze bucket>"
            ]
        },
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObjectVersion",
                "s3:DeleteObject",
                "s3:GetObjectVersion",
                "s3:GetObjectAcl",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::<ze bucket>/*"
            ]
        }
    ]
}

Develop

 $renderer = \Drupal::service('renderer');
   $renderer->addCacheableDependency($build, $config); 
   $renderer->addCacheableDependency($build, $cu); 
 $config = \Drupal::config('system.site');
 $current_user = \Drupal::currentUser();
   $cu = \Drupal\user\Entity\User::load($current_user->id())

use drush

 ./vendor/bin/drush --version
 ./vendor/bin/drush cache:clear
 ./vendor/bin/drush updatedb:status  -vvv
 drush entity:updates

Disable caching

From: https://www.drupal.org/docs/develop/development-tools/disable-caching

  • Add the settings.local.php and
  • Modify development.services.yml:
parameters:
  http.response.debug_cacheability_headers: true
  twig.config:
    debug: true
    auto_reload: true
    cache: false
services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory

ReST



curl --include \
  --request POST \
  --user admin:<> \
  --header 'Content-type: application/hal+json' \
  http://pi.local/node?_format=hal_json \
  --data-binary '{
    "_links": {
      "type":{"href":"http://pi.local/rest/type/node/article"}
    },
    "title":[{"value":"Node +++ 123 bac +++" }],
    "body":[{"value": "<b>hello, wor</b>ld!", "format": "full_html" }],
    "type":[{"target_id":"article"}],
    "status": [{"value": 1}],
    "_embedded": {
      "http://pi.local/rest/relation/node/article/field_issue": [
        { "uuid": [{ "value": "56229a95-d675-43e1-99b1-f9e11b5579c5" }] }
      ],
      "http://pi.local/rest/relation/node/article/field_tags": [
        { "uuid": [{ "value": "45646a7d-1a16-42e8-b758-f6e1c8d976f7" }] },
        { "uuid": [{ "value": "834e34e2-05ae-498d-b876-453798872ce1" }] }
      ]
    }

  }'

Tutorials