1

I have created some BEFs as checkbox list to allow multiple selectios, the filtering options are many, so I want only limited filter options to appear say 5. If I click on more then only it should show the remaining.

for eg:

FILTER OPTIONS op1 op2 op3 . . . opn

I want them to appear as

FILTER OPTIONS op1 op2 op3 op4 op5 more on clicking more link it has to display the remaining options. How ca i achieve this?

  • You can do this with javascript, There is no need to modify Better exposed filter any way. Simply hide few of the checkboxes with js and add a more link. When you click on that show all the hidden checkboxes, and change more link to less – MutantMahesh Aug 8 '14 at 7:47
  • thank you do i need to create a seperate js file handling this or in which file i need to add these changes? – embeeke Aug 8 '14 at 7:49
  • Yes you can add this in separate js file. You can add new js file in your theme but that js file will load on all pages. or You can create small custom module add control that file to include only on that views specific page. Adding code in answer. – MutantMahesh Aug 8 '14 at 8:03
0

As i mentioned in comment you can do this with small custom JS without modifying Better exposed file any way. Create a custom module with hook_form_views_exposed_form_alter()

//MYMODULE.info

name = MY CUSTOM MODULE
description = custom module for hiding extra BEF checkboxes
package = Custom
version = VERSION
core = 7.x 

// MYMODULE.module

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form['#id'] == 'YOUR_VIEWS_EXPOSED_FORM_ID') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'MYMODULE') . '/js/MYMODULE.js' => array(
       'type' => 'file',
     ),
    );
  }
}

// js/MYMODULE.js

(function($, Drupal, window, document, undefined) {
  $(document).ready(function(){
    // your js code goes here with logic to hide and show the extra checkboxes
  });
})(jQuery, Drupal, this, this.document);

Change MYMODULE with your custom module name every where in this code. check jquery api for show, hide functionality, and text for replacing more and less vice versa.

UPDATE:

Changed :

 if ($form_id == 'YOUR_VIEWS_MACHINE_NAME') {

to

 if ($form_id == 'views_exposed_form' && $form['#id'] == 'YOUR_VIEWS_EXPOSED_FORM_ID') {
0

You have to use javascript like show/hide jquery plugin/scripts show/hide jquery plugin/scripts . just take the id of dropdown list and then apply jquery where you want. include jquery script where you mostly write. its upto you.

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.