Skip to content

Commit

Permalink
Add warning if view has exposed filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
kepol committed Jan 29, 2025
1 parent d988eb2 commit f6e6b7c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use Drupal\quant\Plugin\QueueItem\RouteItem;
use Drupal\quant\QuantQueueFactory;
use Drupal\quant\Seed;
use Drupal\quant\Utility;
use Drupal\views\ViewExecutable;

/**
* Implements hook_menu_local_tasks_alter().
Expand Down Expand Up @@ -501,3 +502,16 @@ function quant_preprocess_views_view_table(&$variables) {
}
}
}

/**
* Implements hook_preprocess_views_view().
*/
function quant_preprocess_views_view(array &$variables) {
/** @var ViewExecutable $view */
$view = $variables['view'];

// If the view has exposed filters, add a warning for admins.
if ($view->exposed_data && \Drupal::currentUser()->hasRole('administrator')) {
\Drupal::messenger()->addWarning(t('The view (@view_id) on this page has exposed filters which need special handling for a static website.<br/> <a href="https://docs.quantcdn.io/integrations/drupal">Review the documentation for your options</a>.', ['@view_id' => $view->id()]));
}
}

0 comments on commit f6e6b7c

Please sign in to comment.