Guest User

Untitled

a guest
Mar 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function my_module_form_alter(&$form, &$form_state, $form_id) {
  2. if ($form_id == 'views_exposed_form') {
  3. // Exclude cases when query contains 'field_color_tid'.
  4. if (strpos($_SERVER['QUERY_STRING'],'field_color_tid') === FALSE) {
  5. // Act only if query string contains 'field_size_tid'
  6. if (strpos($_SERVER['QUERY_STRING'],'field_size_tid') !== FALSE) {
  7. $selected_tid = $form_state['view']->exposed_input['field_size_tid'];
  8. // Check if such taxonomy term exists.
  9. $term = taxonomy_term_load($selected_tid);
  10. if (!empty($term)) {
  11. // Redirect to taxonomy page.
  12. $path_alias = drupal_get_path_alias('taxonomy/term/'.$selected_tid);
  13. drupal_goto($path_alias);
  14. }
  15. }
  16. }
  17. }
  18. }
Add Comment
Please, Sign In to add comment