Add javascript

Submitted by root on Fri, 03/04/2022 - 07:50
Code
(function ($) { Drupal.behaviors.funtzioIzen = { attach: function (context, settings) { /* if(!$('#balio-modal-button').length) { $('#edit-group-balioak legend').append('<button id="balio-modal-button">Balioak erakutsi</button>'); }*/ } }; })(jQuery);

drupal_set_message

Submitted by root on Tue, 01/11/2022 - 16:36
Code
\Drupal::messenger()->addError('example error'); \Drupal::messenger()->addStatus('example status'); \Drupal::messenger()->addWarning('example warning'); // --- or in class --- // before class use Drupal\Core\Messenger\MessengerTrait; // into class use MessengerTrait; // call $this->messenger()->addStatus('example message');

Order taxonomy from name

Submitted by root on Tue, 11/23/2021 - 20:20
Code
SELECT tid, langcode, name, SUBSTRING_INDEX(name, ' ', 1), SUBSTRING_INDEX(TRIM (TRAILING '.' FROM SUBSTRING_INDEX(name, ' ', 1)), '.', -1) pisu FROM taxonomy_term_field_data WHERE vid = 'sailkapen' UPDATE taxonomy_term_field_data SET weight = SUBSTRING_INDEX(TRIM (TRAILING '.' FROM SUBSTRING_INDEX(name, ' ', 1)), '.', -1) WHERE vid = 'sailkapen'

Change language switcher links with langcodes

Submitted by root on Thu, 11/26/2020 - 16:54
Code
function CUSTOM_THEME_NAME_preprocess_links__language_block(&$variables) { if( isset($variables['links']['en']) ) { $variables['links']['en']['link']['#title'] = 'EN'; } $variables['links']['es']['link']['#title'] = 'ES'; $variables['links']['eu']['link']['#title'] = 'EU'; if( isset($variables['links']['fr']) ) { $variables['links']['fr']['link']['#title'] = 'FR'; } }

Delete all terms

Submitted by root on Thu, 11/19/2020 - 07:28
Code
<?php $tids = \Drupal::entityQuery('taxonomy_term')->condition('vid', 'mycustomvocab')->execute(); $controller = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $entities = $controller->loadMultiple($tids); $controller->delete($entities); ?>