By admin , 1 May, 2024 Attach photoswipe library to form $form['#attached']['library'][] = 'photoswipe/photoswipe.init'; $template = ['#theme' => 'photoswipe_container']; $form['#attached']['drupalSettings']['photoswipe']['container'] = \Drupal::service('renderer')->renderP Tags form photoswipe
By admin , 5 April, 2024 Drupal Commerce 2 on paid event <?php declare(strict_types=1); namespace Drupal\MYMODULE\EventSubscriber; use Drupal\commerce_order\Event\OrderEvent; Tags commerce event
By admin , 4 April, 2024 Override admin template defined in a contrib module /** * Implements hook_theme(). */ function MY_MODULE_theme($existing, $type, $theme, $path) { return [ 'commerce_order__admin' => [ 'template' => 'commerce-order--admin-custom', ], ]; } Tags template theme
By admin , 3 April, 2024 Inject TimeInterface use Drupal\Component\Datetime\TimeInterface; /** * The controller constructor. */ public function __construct( private readonly TimeInterface $datetimeTime, ) {} Tags dependency injection
By admin , 28 March, 2024 Install partial config drush config-import --partial --source=modules/custom/MYMODULE/config/install/ Tags config drush
By admin , 28 March, 2024 Convert date to another format $new_date = date('d.m.Y', strtotime($existing_date)); Tags date php
By admin , 28 March, 2024 Change existing field type $entityType = 'node'; $fieldName = 'field_myfield'; $new_type = 'text_long'; $database = \Drupal::database(); $table = $entityType . '__' . $fieldName; $rev_table = $entityType . '_revision__' . Tags field
By admin , 27 March, 2024 Drupal 10 show php errors when WSOD Add this string to settings.php or settings.local.php$config['system.logging']['error_level'] = 'verbose'; Tags settings.php wsod errors
By admin , 26 March, 2024 Get string link to user $attributes = [ 'title' => 'View user profile.', ]; $link = $test_user->toLink(NULL, 'canonical', ['attributes' => $attributes])->toString(); Tags user
By admin , 26 March, 2024 Get user (id) from URL $user = \Drupal::routeMatch()->getParameter('user'); Tags user routes