Skip to content

Instantly share code, notes, and snippets.

@opi
opi / README.md
Created June 11, 2021 08:55
Drupal 9 : Migrate D7 body field to paragraph
  1. Run body_to_paragraph migration
  2. Run my_node_migration migration
@opi
opi / drupal_sticky_nav_with_debounce.md
Last active May 6, 2021 09:04
Drupal : Sticky navigation with debounce

In yourtheme.libraries.yml

global:
  js:
    dist/js/global.js: { minified: true }
  dependencies:
    - core/drupal
    - core/drupal.debounce
@opi
opi / ParagraphsBetterSummaryFormatter.php
Created January 29, 2021 08:09
mymodule/src/Plugin/Field/FieldFormatter/ParagraphsBetterSummaryFormatter.php A Better Paragraphs Summary Formatter
<?php
namespace Drupal\mobilis\Plugin\Field\FieldFormatter;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
@opi
opi / OpiToolsCommands.php
Last active January 14, 2021 11:17
Drupal9 - Create field_group from drush command
<?php
namespace Drupal\opitools\Commands;
use Drush\Commands\DrushCommands;
use Drupal\Core\Language\LanguageInterface;
/**
* A Drush commandfile.
*
@opi
opi / drupal7_contrib_update.sh
Created December 4, 2020 08:20
Automate Drupal7 contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / drupal7_core_update.sh
Created December 4, 2020 08:19
Automate Drupal7 core update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / drupal_contrib_update.sh
Created September 14, 2020 08:40
Drupal 7 Contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
@opi
opi / gist:5335785
Last active April 28, 2020 18:27
Drupal 7 : Add translation programmatically
<?php
$report = array(
'skips'=>0,
'updates'=>0,
'deletes'=>0,
'additions'=>0
); // ??
$source = "Sometime drupal sucks";
$translation = "Drupal C DLA BALLE";
@opi
opi / drupal_contrib_update.sh
Created March 9, 2020 09:32
Drupal 7 contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
# Get document root path