Hello,

I was wondering if anyone has built an exposed filter in a block for Exhibit + Views. The idea is that when the exhibit node loads, there will be facets already chosen.

For instance, I could have a Location City as node field for the feeds display on views. I would like to build a block that any user could put a city name into form on that block.

When the form is submitted, the exhibit loads with the city facet chosen.

All the other facets will load and the exhibit would load normally, just the value in the form would serve as criteria for preselecting facets.

The same behavior that happens when you use the Text Search in the block provided by the module. Only I see the block being available on all pages.

Am I making sense?

Thanks,
Zen

Comments

aWileyMcGee’s picture

Issue tags: +exhibit, +Block Form

Got it!!

First you install the Exhibit module:

http://drupal.org/project/exhibit

There are some great links on there by one Josh Huckabee on how to install the exhibit module and get it working with Drupal.

http://joshhuckabee.com/getting-started-exhibit-using-drupal-and-views-p...

http://joshhuckabee.com/getting-started-exhibit-using-drupal-and-views-p...

http://joshhuckabee.com/getting-started-exhibit-using-drupal-and-views-p...

Go ahead and read those, it is fine, I will wait.

Once you have setup your exhibit content type, you can enter into the Facet Definition area, your text search facet.

<div ex:role="facet" ex:facetLabel="Search" ex:facetClass="TextSearch" id="search"></div>

Edit the above line to include this:

ex:queryParamName="srch"

So it will look like this.

<div ex:role="facet" ex:facetLabel="Search" ex:facetClass="TextSearch" id="search" ex:queryParamName="srch"></div>

Then in your custom module you build a block using hook_block.

http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...

/**
 * 
 * Build custom blocks
 * @param $op
 * @param $delta
 * @param $edit
**/
function extanto_custom_block($op = 'list', $delta = 0, $edit = array()){  
 switch ($op) {
   case 'list':
     $blocks[0]['info'] = t('Extanto Custom Block');     
     $blocks[0]['cache'] = BLOCK_NO_CACHE;               
     return $blocks;
     
   case 'view':
     
    if ($delta == 0) {
     $block['subject'] = t('Do The Search');
     $block['content'] = drupal_get_form('extanto_custom_exhibit_search_form');
     return $block; 
     
    }
  }
}

Then you build a form.

http://drupal.org/node/751826

/**
 * 
 * Build Form 
 * 
 */


function extanto_custom_exhibit_search_form() {
  
  $form = array();
  $form['custom_search'] = array(    
    '#type' => 'textfield',
    '#size' => 20,
    '#maxlength' => 255,      
    '#suffix' => t('</div>'),    
  );   
    
  $form['submit'] = array(
    '#prefix' => t('<div id="searchWrap-nav-go">'),
    '#type' => 'image_button',
    '#value' => '',      
    '#suffix' => t('</div>'),    
  );     
   
  return $form;
}

Then in your submit function you use drupal_goto, like the following:

function extanto_custom_exhibit_search_form_submit($form, &$form_state) {
 
  $query = array(
  	'srch' => $form_state['values']['custom_search'],
  ); 
  
  return drupal_goto($path = '/content/use-my-search', $query, $fragment = NULL, $http_response_code = 302);
}
aWileyMcGee’s picture

Assigned: Unassigned » aWileyMcGee
Status: Active » Fixed

I am setting this to fixed as my question has been answered. I hope this helps other folks.

Resolved,

Zen

Automatically closed -- issue fixed for 2 weeks with no activity.