You need to start with:
((Drupal) => {
Drupal.behaviors.nameOfLibrary = {
attach(context) {Then it ends with:
| You need to start with: | |
| ```js | |
| ((Drupal) => { | |
| Drupal.behaviors.nameOfLibrary = { | |
| attach(context) { | |
| ``` | |
| Then it ends with: | |
| ```js | |
| }, |
Here's a gulp function that hops through the directory structure and compiles css files in the same directory as the corresponding scss file. It’s as simple as our current gulp routine, so we don’t have to abandon scss to use Single Directory Components unless we want to for other reasons
/* This will compile individual css files in the same directory as the corresponding scss file */
function sdcscss() {
return gulp
.src("./assets/styles/**/*.scss", {
base: "./assets/styles/",
})
.pipe(sassGlob({}))| The magic secret is the drupal_entity function! | |
| ```twig | |
| {% set object = drupal_entity('ENTITY_TYPE', ID, 'VIEW_MODE')) %} | |
| ``` | |
| Ex: | |
| ```twig | |
| {% set object = drupal_entity('node', 123, 'default')) %} | |
| ``` |
If you’d like to use a GUI database client, you’ll need the right connection details and there may even be a command to launch it for you:
| ## The command: | |
| ```bash | |
| drush php-eval "echo \Drupal::service('uuid')->generate();" | |
| ``` | |
| Preface with `lando` or `ddev` or whatever as needed for your local dev environment | |
| Note that it'll generate the UUID, then it'll append a % as the program exits. Don't use the % in your UUID 😆 | |
| ## Example: |
| 1. Make sure your composer file includes the following: | |
| ```yml | |
| "extra": { | |
| "installer-paths": { | |
| ... | |
| "recipes/{$name}": [ | |
| "type:drupal-recipe" | |
| ] | |
| } | |
| } |
The basic plan:
{% set imagePath = 'public://images/default.jpg' %}
{% set responsiveimagestyle = {
'#theme': 'responsive_image',
'#responsive_image_style_id': 'my_responsive_image_style_id',
'#uri': imagePath,
'#alt': 'my alt text',
'#attributes': { class: 'img-responsive', alt: 'my alt text' },
} %}A commit should be a wrapper for related changes. For example, fixing two different bugs should produce two separate commits. Small commits make it easier for other developers to understand the changes and roll them back if something went wrong. With tools like the staging area and the ability to stage only parts of a file, Git makes it easy to create very granular commits.
Committing often keeps your commits small and, again, helps you commit only related changes. Moreover, it allows you to share your code more frequently with others. That way it‘s easier for everyone to integrate changes regularly and avoid having merge conflicts. Having large commits and sharing them infrequently, in contrast, makes it hard to solve conflicts.
| <?php | |
| namespace Drupal\prc_helper\Plugin\Field\FieldFormatter; | |
| use Drupal\Core\Field\FieldItemListInterface; | |
| use Drupal\Core\Field\FormatterBase; | |
| use Drupal\Core\Form\FormStateInterface; | |
| use Drupal\media\Entity\Media; | |
| /** |