Search block returns a url like domain_name/search/site, instead of domain_name/site_name/langcode/search/site. So, it is not working for multiple_sited installation.

For your reference, below is the comparison of code of wxt search block and drupal core search block.

Drupal core:
// Set up the form to submit using GET to the correct search page.
$entity_id = $this->searchPageRepository->getDefaultSearchPage();

// SearchPageRepository::getDefaultSearchPage() depends on search.settings.
// The dependency needs to be added before the conditional return, otherwise
// the block would get cached without the necessary cacheablity metadata in
// case there is no default search page and would not be invalidated if that
// changes.
$this->renderer->addCacheableDependency($form, $this->configFactory->get('s$

./core/modules/search/src/Form/SearchBlockForm.php if (!$entity_id) {
$form['message'] = [
'#markup' => $this->t('Search is currently disabled'),
];
return $form;
}

$route = 'search.view_' . $entity_id;
$form['#action'] = $this->url($route);

WXT8:

$wxt_active = $this->wxtLibraryServiceWxT->getLibraryName();
$submit_title = $this->t('Search');

$form['#action'] = '/search/site';

Comments

peijun created an issue. See original summary.

sylus’s picture

Ah I have reproduced this, will be taking a look over the weekend or so as have the same requirement.

Thanks for letting us be aware of this.

sylus’s picture

So that code is conditional based on whether search api is enabled:

  public function build() {
    // Add search block but only if search functionality exists.
    if ($this->moduleHandler->moduleExists('search_api')) {
      return $this->formBuilder->getForm('Drupal\wxt_library\Form\SearchApiBlockForm');
    }
    elseif ($this->moduleHandler->moduleExists('search')) {
      return $this->formBuilder->getForm('Drupal\wxt_library\Form\SearchBlockForm');
    }
    else {
      return [];
    }

Will look at whether can handle via routes rather then hardcoding /search/site so can get context.

sylus’s picture

Status: Active » Closed (works as designed)

I think for reference this largely solves the problem of the overridding:

https://www.drupal.org/project/wxt/issues/3195726

For a multi-site install where the view pages paths can change using search api, you would likely need to make your own block but it should be as a simple as extending the search api block we provide now atm.

I'd happily take a patch that checked the views pages and determined the path via a drop down but for now hoping this issue is largely superceded.

Thanks so much :D