The javascript function "getAdditionalQueryParameters" doesn't correctly detect facets passed in url if there is a number between brackets:

http://domain.tld/search-page?f[0]=products%253Atype%3A10&order=asc&sort=

After enabling a new facet, this generates a strange URL:

http://domain.tld/search-page?f[]=products%253Aauthor%3A250&order=asc&so...

Here is my fix:

File: misc/ajax_facets.js

         // Remove brackets from multiple parameter.
-        pair[0] = pair[0].replace('[]', '');
+        pair[0] = pair[0].replace(/\[\d*\]/, '');
 
         // We interested only in additional parameters but not in facet parameters.

Hope it helps someone.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sebastien @Actualys created an issue. See original summary.

Sebastien M.’s picture

Status: Active » Needs review
FileSize
482 bytes

Here is my patch.

eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi

Thank you for your report, but I should reproduce this problem.

The javascript function "getAdditionalQueryParameters" doesn't correctly detect facets passed in url if there is a number between brackets:
http://domain.tld/search-page?f[0]=products%253Atype%3A10&order=asc&sort=

How can I reproduce situation when I'll have number between brackets? I have tried to activate some facets but my brackets are always without numbers.

Sebastien M.’s picture

Status: Postponed (maintainer needs more info) » Needs review

Hi Eugene,

It is not directly generated by this module.
Indeed, when you forge a search url with facets like that :


$url = url('search-page', array('query' => array('query' => 'search word', 'f' => array('product%3Atype:mug'))));
echo $url;

This will result in this url :

scripts/search-page?query=search%20word&f[0]=product%253Atype%3Amug

Once a page is called with a such url, javascript is not able to handle correctly facets from the url.

I hope I could explain this issue to allow you to reproduce it.
Many thanks

eugene.ilyin’s picture

Yes, you are right.

Thank you Sebastien!

Committed.

eugene.ilyin’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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