Timeline all
#69
Saw Courtney Barnett this weekend. Give me all your money, and I'll make some origami honey. I should buy the t-shirt :) https://www.youtube.com/watch?v=xV_zbJ8SflU
#67
Testing repost on fediverse
#59
#58
Exclude entities which have a redirect from the search api index
For a custom project, we use a taxonomy to tag nodes. Some terms have their own page, while others redirect to a node. The search on the site has one index which contains both nodes and terms, but the terms which are redirecting shouldn't show up when viewing a search results page. While it's possible to use hook_search_api_index_items_alter(), a nicer way to exclude them is by using a processor plugin so you can enable them in the UI per index. The relevant code is underneath. Adjust to your own likings - and maybe inject the service if you want to as well :)
<?phpnamespace Drupal\project\Plugin\search_api\processor;use Drupal\search_api\IndexInterface;use Drupal\search_api\Processor\ProcessorPluginBase;/** * Excludes entities which have a redirect. * * @SearchApiProcessor( * id = "entity_redirect", * label = @Translation("Entity redirect"), * description = @Translation("Exclude entities which have a redirect from being indexed."), * stages = { * "alter_items" = 0, * }, * ) */class EntityRedirect extends ProcessorPluginBase { /** * {@inheritdoc} */ public static function supportsIndex(IndexInterface $index) { foreach ($index->getDatasources() as $datasource) { $entity_type_id = $datasource->getEntityTypeId(); if (!$entity_type_id) { continue; } if ($entity_type_id === 'node' || $entity_type_id == 'taxonomy_term') { return TRUE; } } return FALSE; } /** * {@inheritdoc} */ public function alterIndexedItems(array &$items) { $repository = \Drupal::service('redirect.repository'); $pathAliasmanager = \Drupal::service('path.alias_manager'); /** @var \Drupal\search_api\Item\ItemInterface $item */ foreach ($items as $item_id => $item) { $object = $item->getOriginalObject()->getValue(); try { $path = $object->toUrl()->toString(); $path = $pathAliasmanager->getPathByAlias($path); $path = ltrim($path, '/'); $redirect = $repository->findMatchingRedirect($path); if (!empty($redirect)) { unset($items[$item_id]); } } catch (\Exception $ignored) {} } }}?>
#48
#46
PWA for D7
The PWA module for Drupal now has a Drupal 7 release, nice!
#42
#41
Repost of https://mastodon.technology/@snarfed/3194674
Testing Drupal integration with https://fed.brid.gy/
#25
Pity to hear that Stake number eight is retiring. Great band, and not afraid to shoot dark, yet funny clips. https://youtu.be/AvQDfl0PuqA is great to watch, especially if you know Gent a bit :)
#15
#12
#6
De splitsing
Last year I spent a lot of evenings writing a script for a play I had in mind. And finally it's there, the first production is coming the first weekend of december. You are all invited! If you don't understand dutch, make your own story while watching, who knows we come up with an idea for another play :) More information and tickets reservation are available on okermaan.be
swentel on Wed, 03/10/2018 - 08:06
Oh awesome! I will look it up to print it and hide maybe one too in Belgium if that's ok for you :) I will add credits of course on the cache info !