Hi!

Hi tried to modify the function views_fastsearch_form_alter, removing the TODO comments inside.

function views_fastsearch_form_alter($form_id, &$form) {
  if ($form_id == 'search_theme_form') {
    if ($view = views_get_view('views_fastsearch')) {
      $views_status = variable_get('views_defaults', array());
      if ($views_status[$view->name] == 'enabled' || (!$view->disabled && $views_status[$view->name] != 'disabled')) {
      
/* @TODO: this isn't quite working yet */
        $form['filter0'] = $form[$form_id .'_keys'];
        $form['filter0']['#weight'] = -1;
        unset($form[$form_id .'_keys']);
        unset($form['#base']);
        unset($form['#submit']['search_box_form_submit']);
        $form['#action'] = url($view->url);

      }
    }
  }

Now, default search button runs 'views fast search' (WOW!). But I understand now why it's a TODO-version code: value field for search doesn't work (I obtain always no results, as well as a string is keyed into field).

Is there a new version of this function that runs at 100%?

Many thx,
Alessandro

Comments

douggreen’s picture

All you need to do is override the search_theme_form (you should put this in your own custom module):

/**
 * Override drupal_get_form('search_theme_form') to return a form that the
 * search/all page and the view filter search
 */
function search_theme_form() {
  $form['filter0'] = array(
    '#type' => 'textfield',
    '#size' => 15,
    '#default_value' => $_GET['filter0'],
    '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
  );
  $form['#submit'] = array('yourmodule_search_form_submit' => array());

  return $form;
}

function yourmodule_search_form_submit($form_id, $form) {
  drupal_goto('search/fast', 'filter0='. drupal_urlencode($form['filter0']));
}

I haven't put this code into views_fastsearch, because you can only have one search_theme_form, and if I were to override it here, then others couldn't also override it.

I've meant to write an article on this, but haven't gotten around to it.

alex72rm’s picture

Sorry, I'm trying to apply your hints but I don't reach my goal.

I should override search_theme_form in my custom module, but I haven't a custom module.
I have only installed your module.

If I put your replacing function into views_fastsearch.module, it runs as the commented code that I used before (the one you write that doesn't run well).

The final result is that if I write down a search string into the default module, it goes directly to fastsearch view, but with no results. I must input again the search string there, and then I obtain what I'm searching for.

Thx,
Alessandro

douggreen’s picture

To use this technique, you should put this code in a custom module for your site. Yes, you can put it in the views_fastsearch.module code, but that's poor style. You shouldn't modify contrib modules in this way, if you want to be flexible to upgrade them in the future.

alex72rm’s picture

Status: Active » Closed (fixed)

Uhm, this doesn't run anyway.
My final code is really poor style: I put a little bit of your code into search.module:

function search_box_form_submit($form_id, $form_values) {
  //return 'search/node/'. trim($form_values[$form_id .'_keys']);
  drupal_goto('search/fast', 'filter0='. trim($form_values[$form_id .'_keys']));
}

And not it runs! :-)

Alessandro

nimzie’s picture

I have found this thread and it is exactly what I am trying.

I am not sure of the steps to make the module nor am I understanding what should be in there (and not in there).

I did try the suggestion Alex72RM put in #4 and it almost works.

The issue I am having is weird - and may have nothing to do with this fix.

In my theme, when I run the search, and get terms - the rss icon shows, but it's showing an internal link (and the icon isn't clickable).

This works with and without search results from Garland. Exactly as I would like.

So - what could I be missing?

I am outputting the links in page.tpl.php as:
<?php print $feed_icons ?>

The icon is showing and is clearly being output, however when I hover over it (if there are results), the link isn't active - and the href is pointing to "xampp/site/search/fast..." instead of http://localhost/etc

this seems to be where the problem lies, but why - with the exact same code is Garland working and this is not?

I have a custom search box in my theme:

<form action="<?php print base_path() ?>search/node/"  accept-charset="UTF-8" method="post" id="search-block-form">
<input type="text" name="search_block_form_keys" id="edit-search-block-form-keys"  class="search_internal form-text swap_value" />
    <input type="hidden" name="op" id="edit-submit" value="Search"  class="form-submit"  />	
	<input type="hidden" name="edit[form_token]" id="edit-search-block-form-form-token" value="<?php print drupal_get_token('search_form'); ?>" />
    <input type="hidden" name="form_id" id="edit-search-block-form" value="search_block_form"  />
</form>

however if I do this same search from the fast search filter box (in the search fast form), it works the same (no working link for successful searches).

Please advise. This is quite confusing to me.

Cheers,
Adam

alex72rm’s picture

Feed icons should be written *always* with conditional statements.

	<?php if ($feed_icons): ?>
          <div class="feed-icons"><?php print $feed_icons; ?></div>
        <?php endif; ?>

Then, if RSS link doesn't appear, the cause is probably related to the absence of a taxonomy term associated to the content type.
If this is the case, you should use views RSS module (that you can find and configure from views) to obtain your RSS feed for a generic cck content type.

But now a question: why have you wrote down a request on a RSS problem here (a views fastsearch thread)? lol

Alessandro