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
By admin, 26 March, 2024 Render BlockBase programmatically /** * Implements hook_ENTITY_TYPE_view(). */ function my_module_user_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { if ($display->getComponent('my_block')) { $block = \Drupal::service('plugin.manager.block')->createInstanc Tags block render
By admin, 26 March, 2024 Render views block programmatically /** * Implements hook_ENTITY_TYPE_view(). */ function my_module_user_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) { if ($display->getComponent('my_module')) { $view = Views::getView('my_module_block'); Tags block views render
By admin, 11 March, 2024 If current user has permission \Drupal::currentUser()->hasPermission('my permission'); Tags permissions
By admin, 11 March, 2024 Add message to watchdog \Drupal::logger('my_module')->info('Info'); Tags watchdog logger
By admin, 29 February, 2024 Disable reaching a node by its internal path (node id) use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\node\NodeInterface; function MYMODULE_preprocess_page Tags access
By admin, 17 February, 2024 Form template: render field separately <form{{ attributes }}> <div class="wrapper d-flex"> <div class="left"> Tags twig form