Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. function mytheme_preprocess_views_view($variables) {
  2. if($variables['id'] == 'myview_id') {
  3. use DrupalCorePluginPluginBase;
  4.  
  5. $facet_id = 'facet_type';
  6. $render = [];
  7. $block_manager = Drupal::service('plugin.manager.block');
  8. $config = [];
  9. $block_plugin = $block_manager->createInstance('facet_block' . PluginBase::DERIVATIVE_SEPARATOR . $facet_id, $config);
  10. if ($block_plugin) {
  11. $access_result = $block_plugin->access(Drupal::currentUser());
  12. if ($access_result) {
  13. $render = $block_plugin->build();
  14. }
  15. }
  16. if (!empty($render)) {
  17. $variables[$facet_id] = [
  18. 'title' => 'Type',
  19. 'render' => $render,
  20. ];
  21. }
  22. }
  23.  
  24. {{ facet_type }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement