By admin , 17 August, 2023 Flat multidimensional array of entity id's $tags = $form_state->getValue('tags'); $flat_tags = []; array_walk_recursive($tags, static function ($a) use (&$flat_tags) { $flat_tags[] = $a; }); // Or simple: $flat_tags = array_column($tags, 'target_id'); Tags entity php array
By admin , 8 August, 2023 Inject cache_tags.invalidator service to form use Drupal\Core\Cache\CacheTagsInvalidator; ... /** * The cache tags invalidator. */ protected CacheTagsInvalidator $cacheTagsInvalidator; /** * Constructs a form object. * * @param \Drupal\Core\Cache\CacheTagsInvalidator $cache_tags_invalidator * The cache Tags dependency injection form cache
By admin , 2 August, 2023 Views with photoswipe slides not scroll Needs to add view global css class "photoswipe-gallery" Tags photoswipe views
By admin , 2 August, 2023 jQuery: find element with part of class $("jdiv[class*='button_']").addClass('jivosite-button'); Tags jquery
By admin , 30 July, 2023 jQuery: smooth scroll to ID $('html, body').animate({ scrollTop: $("#tour-desc").offset().top }, 500); Tags jquery
By admin , 30 July, 2023 Twig Tweak render content block {{ drupal_block('block_content:c80b81c4-e8ff-43d6-b9f9-6d547afb67c0') }} Tags twig
By admin , 28 July, 2023 Hide an exposed filter block if the view results are empty /** * Implements hook_views_pre_render(). */ function mymodule_views_pre_render(ViewExecutable $view) { if ($view->storage->id() == 'myview' && $view->current_display == 'block_1') { if (empty($view-> Tags views exposed form
By admin , 26 July, 2023 Render "Page Manager" page programmatically in controller $page = Page::load('page_name'); if ($page) { $variants = $page->getVariants(); $pageVariant = end($variants); if ($pageVariant) { $viewer = new PageVariantViewBuilder(); if ($viewer) { return $viewer->view($pageVariant); } } } Tags render controller page manager
By admin , 17 July, 2023 Get current url in twig {% set url = url('<current>') %} {% if 'reviews' in url|render|render %} <div class="reviews"></div> Tags twig url
By admin , 7 July, 2023 Get entity translation $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); if ($term->hasTranslation($language)) { $term_translated = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language); $term_title = $term_translated->getName(); } Tags translate