0

I have a page view which works fine for two cases in the exposed filter (say school one and school two).

However, if school three is chosen in the exposed filter, I want another view to be displayed instead of the page view for school one and school two.

I don't mind if it's a block view or page. Just to call another view because its display is different (a summary of school one and two in addition to school three)

@No Sssweat

  • 1
    You can add JS for this. If exposed filter value is "school three" then display block for another view. Otherwise that view is hidden and show present view. – amruta.k May 25 '16 at 12:27
  • Wao! A brilliant idea. But where do i add the JavaScript? In the themes folder or in the created views? – adigunsherif May 25 '16 at 12:52
  • 1
    Add custom js file in themes folder and add path in .info file of theme. – amruta.k May 26 '16 at 4:24
1

Wao! A brilliant idea. But where do i add the JavaScript? In the themes folder or in the created views?

In template.php located in sites/all/themes/yourtheme

Add the following code at the bottom:

function yourtheme_views_pre_render(&$view) {

   if ($view->name == 'view_name') {
    drupal_add_js(drupal_get_path('theme', 'yourtheme') . '/js/custom.js');
   } 
}
  • replace yourtheme with you actual name of your theme.
  • replace view_name with your view name.

Also, you'll need to wrap/format your jQuery code like this

/sites/all/themes/yourtheme/js/custom.js

(function($) {

    //your code goes here

})(jQuery);

PS: Don't forget to clear the cache to see the changes.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.