Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
facets
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
8
Merge Requests
8
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
facets
Commits
fe311204
Commit
fe311204
authored
Jul 24, 2017
by
borisson_
Committed by
borisson_
Jul 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2827808
by borisson_: Facets on multilangual site
parent
9064a63c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
README.txt
README.txt
+7
-0
tests/src/Functional/LanguageIntegrationTest.php
tests/src/Functional/LanguageIntegrationTest.php
+51
-0
No files found.
README.txt
View file @
fe311204
...
...
@@ -146,3 +146,10 @@ the chosen module (and others, probably) doesn't find the select element.
So the library should be attached to the block in custom code, we haven't done
this in facets because we don't want to support all possible frameworks.
See https://www.drupal.org/node/2853121 for more information.
Q: Why are facets results links from another language showing in the facet
results?
A: Facets use the same limitations as the query object passed, so when using
views, add a filter to the view to limit to one language.
Otherwise, this is solved by adding a `hook_search_api_query_alter()` that
limits the results to the current language.
tests/src/Functional/LanguageIntegrationTest.php
View file @
fe311204
...
...
@@ -151,6 +151,57 @@ class LanguageIntegrationTest extends FacetsTestBase {
$this
->
clickLink
(
'item'
);
$this
->
assertTrue
(
strpos
(
$this
->
getUrl
(),
'xx-lolspeak/'
),
'Found the language code in the url'
);
$this
->
assertTrue
(
strpos
(
$this
->
getUrl
(),
'tyto_alba'
),
'Found the facet in the url'
);
}
/**
* Tests facets where the count is different per language.
*
* @see https://www.drupal.org/node/2827808
*/
public
function
testLanguageDifferences
()
{
$entity_test_storage
=
\
Drupal
::
entityTypeManager
()
->
getStorage
(
'entity_test_mulrev_changed'
);
$entity_test_storage
->
create
([
'name'
=>
'foo bar baz'
,
'body'
=>
'test test'
,
'type'
=>
'item'
,
'keywords'
=>
[
'orange'
,
'lol'
],
'category'
=>
'item_category'
,
'langcode'
=>
'xx-lolspeak'
,
])
->
save
();
$entity_test_storage
->
create
([
'name'
=>
'foo bar baz'
,
'body'
=>
'test test'
,
'type'
=>
'item'
,
'keywords'
=>
[
'orange'
,
'rofl'
],
'category'
=>
'item_category'
,
'langcode'
=>
'xx-lolspeak'
,
])
->
save
();
$id
=
'water_bear'
;
$this
->
createFacet
(
'Water bear'
,
$id
,
'keywords'
);
$this
->
drupalGet
(
'admin/config/search/search-api/index/'
.
$this
->
indexId
.
'/edit'
);
$this
->
assertEquals
(
2
,
$this
->
indexItems
(
$this
->
indexId
),
'2 items were indexed.'
);
$this
->
drupalGet
(
'search-api-test-fulltext'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'grape'
);
$this
->
assertSession
()
->
pageTextContains
(
'rofl'
);
$this
->
drupalPostForm
(
NULL
,
[
'language'
=>
'xx-lolspeak'
],
'Search'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'rofl'
);
$this
->
assertSession
()
->
pageTextNotContains
(
'grape'
);
$this
->
drupalPostForm
(
NULL
,
[
'language'
=>
'en'
],
'Search'
);
$this
->
assertFacetBlocksAppear
();
$this
->
assertSession
()
->
pageTextContains
(
'orange'
);
$this
->
assertSession
()
->
pageTextContains
(
'grape'
);
$this
->
assertSession
()
->
pageTextNotContains
(
'rofl'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment